Advertisement
samuelrichter66

craftmine

May 24th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.11 KB | None | 0 0
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do
  6. print("FE Compatibility code V2 by Mokiros")
  7. local RealPlayer = RealPlayer
  8. script.Parent = RealPlayer.Character
  9.  
  10. --Fake event to make stuff like Mouse.KeyDown work
  11. local Disconnect_Function = function(this)
  12. this[1].Functions[this[2]] = nil
  13. end
  14. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  15. local FakeEvent_Metatable = {__index={
  16. Connect = function(this,f)
  17. local i = tostring(math.random(0,10000))
  18. while this.Functions[i] do
  19. i = tostring(math.random(0,10000))
  20. end
  21. this.Functions[i] = f
  22. return setmetatable({this,i},Disconnect_Metatable)
  23. end
  24. }}
  25. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  26. local function fakeEvent()
  27. return setmetatable({Functions={}},FakeEvent_Metatable)
  28. end
  29.  
  30. --Creating fake input objects with fake variables
  31. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  32. FakeMouse.keyUp = FakeMouse.KeyUp
  33. FakeMouse.keyDown = FakeMouse.KeyDown
  34. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  35. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  36. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  37. end}
  38. --Merged 2 functions into one by checking amount of arguments
  39. CAS.UnbindAction = CAS.BindAction
  40.  
  41. --This function will trigger the events that have been :Connect()'ed
  42. local function TriggerEvent(self,ev,...)
  43. for _,f in pairs(self[ev].Functions) do
  44. f(...)
  45. end
  46. end
  47. FakeMouse.TriggerEvent = TriggerEvent
  48. UIS.TriggerEvent = TriggerEvent
  49.  
  50. --Client communication
  51. local Event = Instance.new("RemoteEvent")
  52. Event.Name = "UserInput_Event"
  53. Event.OnServerEvent:Connect(function(plr,io)
  54. if plr~=RealPlayer then return end
  55. FakeMouse.Target = io.Target
  56. FakeMouse.Hit = io.Hit
  57. if not io.isMouse then
  58. local b = io.UserInputState == Enum.UserInputState.Begin
  59. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  60. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  61. end
  62. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  63. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  64. end
  65. for _,t in pairs(CAS.Actions) do
  66. for _,k in pairs(t.Keys) do
  67. if k==io.KeyCode then
  68. t.Function(t.Name,io.UserInputState,io)
  69. end
  70. end
  71. end
  72. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  73. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  74. end
  75. end)
  76. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  77. local Mouse = owner:GetMouse()
  78. local UIS = game:GetService("UserInputService")
  79. local input = function(io,RobloxHandled)
  80. if RobloxHandled then return end
  81. --Since InputObject is a client-side instance, we create and pass table instead
  82. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  83. end
  84. UIS.InputBegan:Connect(input)
  85. UIS.InputEnded:Connect(input)
  86.  
  87. local h,t
  88. --Give the server mouse data every second frame, but only if the values changed
  89. --If player is not moving their mouse, client won't fire events
  90. local HB = game:GetService("RunService").Heartbeat
  91. while true do
  92. if h~=Mouse.Hit or t~=Mouse.Target then
  93. h,t=Mouse.Hit,Mouse.Target
  94. Event:FireServer({isMouse=true,Target=t,Hit=h})
  95. end
  96. --Wait 2 frames
  97. for i=1,2 do
  98. HB:Wait()
  99. end
  100. end]==],script)
  101.  
  102. ----Sandboxed game object that allows the usage of client-side methods and services
  103. --Real game object
  104. local RealGame = game
  105.  
  106. --Metatable for fake service
  107. local FakeService_Metatable = {
  108. __index = function(self,k)
  109. local s = rawget(self,"_RealService")
  110. if s then
  111. return typeof(s[k])=="function"
  112. and function(_,...)return s[k](s,...)end or s[k]
  113. end
  114. end,
  115. __newindex = function(self,k,v)
  116. local s = rawget(self,"_RealService")
  117. if s then s[k]=v end
  118. end
  119. }
  120. local function FakeService(t,RealService)
  121. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  122. return setmetatable(t,FakeService_Metatable)
  123. end
  124.  
  125. --Fake game object
  126. local FakeGame = {
  127. GetService = function(self,s)
  128. return rawget(self,s) or RealGame:GetService(s)
  129. end,
  130. Players = FakeService({
  131. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  132. },"Players"),
  133. UserInputService = FakeService(UIS,"UserInputService"),
  134. ContextActionService = FakeService(CAS,"ContextActionService"),
  135. RunService = FakeService({
  136. _btrs = {},
  137. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  138. BindToRenderStep = function(self,name,_,fun)
  139. self._btrs[name] = self.Heartbeat:Connect(fun)
  140. end,
  141. UnbindFromRenderStep = function(self,name)
  142. self._btrs[name]:Disconnect()
  143. end,
  144. },"RunService")
  145. }
  146. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  147. FakeGame.service = FakeGame.GetService
  148. FakeService(FakeGame,game)
  149. --Changing owner to fake player object to support owner:GetMouse()
  150. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  151. end
  152.  
  153.  
  154.  
  155. -- ORIGINAL CREATOR: Depr1
  156. --Fixed lags by stommmDev for toasters if the creator wants to shut down this script i will
  157. -- If this script isn't on pastebin or the user who uploaded this isn't called "Delros12"
  158. -- (and yes my pastebin account is Delros12) or the link is not https://pastebin.com/2NNDTLjL
  159. -- then this is not the original link of this script.
  160.  
  161. -- The original link of the script gets edited constantly for updates, if you use the original
  162. -- link you will be able to enjoy the most recent updates of this script without changing to
  163. -- another link which contains updated script.
  164.  
  165. -- Enjoy! :)
  166.  
  167. -- Controls: Q to sneak, use the keypad numbers 1-9 to change blocks, choose a empty slot i
  168. -- you want to remove a block.
  169.  
  170. -- this script will transform you into steve when used
  171.  
  172. local targetName = game.Players.LocalPlayer.Name
  173. local player = game.Players:FindFirstChild(targetName)
  174. function putTexture(part, frontF, backF, topF, bottomF, leftF, rightF, className)
  175. local faces = {"Front", "Back", "Top", "Bottom", "Left", "Right"}
  176. for i,f in pairs(faces) do
  177. local decal = Instance.new(className, part)
  178. if i == 1 then decal.Texture = frontF decal.Name = f end
  179. if i == 2 then decal.Texture = backF or frontF decal.Name = f end
  180. if i == 3 then decal.Texture = topF or frontF decal.Name = f end
  181. if i == 4 then decal.Texture = bottomF or frontF decal.Name = f end
  182. if i == 5 then decal.Texture = leftF or frontF decal.Name = f end
  183. if i == 6 then decal.Texture = rightF or frontF decal.Name = f end
  184. decal.Face = f
  185. end
  186. return part
  187. end
  188. function makeSquare(position, size, color, transparency, parent)
  189. local label = Instance.new("TextLabel", parent)
  190. label.Text = ""
  191. label.BorderSizePixel = 0
  192. label.BackgroundTransparency = transparency
  193. label.Position = position
  194. label.Size = size
  195. label.BackgroundColor3 = color
  196. end
  197. function putToolBarSlot(position, image)
  198. local playerGui = player:FindFirstChild("PlayerGui")
  199. if playerGui then
  200. local gui = playerGui:FindFirstChild("ToolBar") or Instance.new("ScreenGui", playerGui)
  201. gui.Name = "ToolBar"
  202. local slot = Instance.new("ImageLabel", gui)
  203. slot.Position = position
  204. slot.Size = UDim2.new(0, 32, 0, 32)
  205. slot.BackgroundTransparency = 1
  206. slot.ImageTransparency = 0
  207. slot.Image = image
  208. slot.ZIndex = 2
  209.  
  210. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 32, 0, 32),
  211. Color3.new(95/255, 89/255, 76/255), 0, slot)
  212. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 2, 0, 32),
  213. Color3.new(0/255, 0/255, 0/255), 0.5, slot)
  214. makeSquare(UDim2.new(0, 2, 0, 0), UDim2.new(0, 30, 0, 2),
  215. Color3.new(0/255, 0/255, 0/255), 0.5, slot)
  216. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 36, 0, 2),
  217. Color3.new(106/255, 106/255, 106/255), 0, slot)
  218. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 2, 0, 36),
  219. Color3.new(106/255, 106/255, 106/255), 0, slot)
  220. makeSquare(UDim2.new(0, 0, 0, 32), UDim2.new(0, 34, 0, 2),
  221. Color3.new(130/255, 130/255, 130/255), 0, slot)
  222. makeSquare(UDim2.new(0, 32, 0, 0), UDim2.new(0, 2, 0, 34),
  223. Color3.new(130/255, 130/255, 130/255), 0, slot)
  224. makeSquare(UDim2.new(0, -4, 0, -2), UDim2.new(0, 2, 0, 38),
  225. Color3.new(130/255, 130/255, 130/255), 0, slot)
  226. makeSquare(UDim2.new(0, 34, 0, -2), UDim2.new(0, 2, 0, 36),
  227. Color3.new(106/255, 106/255, 106/255), 0, slot)
  228. makeSquare(UDim2.new(0, -2, 0, 34), UDim2.new(0, 38, 0, 2),
  229. Color3.new(106/255, 106/255, 106/255), 0, slot)
  230. makeSquare(UDim2.new(0, -4, 0, -4), UDim2.new(0, 40, 0, 2),
  231. Color3.new(156/255, 156/255, 156/255), 0, slot)
  232. end
  233. end
  234. function divide(x, d)
  235. if x ~= 0 and d ~= 0 then
  236. return x/d
  237. else
  238. return x
  239. end
  240. end -- so it doesn't divide by zero
  241. function getDistance(v1, v2)
  242. return math.abs((Vector3.new(math.abs(v2.X - v1.X), math.abs(v2.Y - v1.Y), math.abs(v2.Z - v1.Z))).Magnitude)
  243. end
  244. function round(x)
  245. if x%2 ~= 0.5 then
  246. return math.floor(x+0.5)
  247. end
  248. return x-0.5
  249. end
  250. function weldTo(part1, part2)
  251. local weld = Instance.new("Weld", part1)
  252. weld.Part0 = part1
  253. weld.Part1 = part2
  254. end
  255. function getMagnitudeXZ(velocity)
  256. return math.abs(velocity.X) + math.abs(velocity.Z)
  257. end
  258. function placeBlock(block, cFPos)
  259. local blockPlaced = Instance.new("Part", workspace)
  260. blockPlaced.Material = "Fabric"
  261. blockPlaced.Anchored = true
  262. blockPlaced.Size = block.size
  263. blockPlaced.CFrame = cFPos
  264. putTexture(blockPlaced, block.frontTex, block.backTex,
  265. block.topTex, block.bottomTex, block.leftTex, block.rightTex, "Texture")
  266. return blockPlaced
  267. end
  268. local toolBar = {
  269. Dirt = {
  270. size = Vector3.new(2.6, 2.6, 2.6),
  271. frontTex = "rbxassetid://179655033",
  272. backTex = "rbxassetid://179655033",
  273. topTex = "rbxassetid://179655033",
  274. bottomTex = "rbxassetid://179655033",
  275. leftTex = "rbxassetid://179655033",
  276. rightTex = "rbxassetid://179655033"
  277. },
  278. Grass = {
  279. size = Vector3.new(2.6, 2.6, 2.6),
  280. frontTex = "rbxassetid://96430337",
  281. backTex = "rbxassetid://96430337",
  282. topTex = "rbxassetid://96430265",
  283. bottomTex = "rbxassetid://179655033",
  284. leftTex = "rbxassetid://96430337",
  285. rightTex = "rbxassetid://96430337"
  286. },
  287. Stone = {
  288. size = Vector3.new(2.6, 2.6, 2.6),
  289. frontTex = "rbxassetid://75880927",
  290. backTex = "rbxassetid://75880927",
  291. topTex = "rbxassetid://75880927",
  292. bottomTex = "rbxassetid://75880927",
  293. leftTex = "rbxassetid://75880927",
  294. rightTex = "rbxassetid://75880927"
  295. },
  296. Diamond_Ore = {
  297. size = Vector3.new(2.6, 2.6, 2.6),
  298. frontTex = "rbxassetid://57928490",
  299. backTex = "rbxassetid://57928490",
  300. topTex = "rbxassetid://57928490",
  301. bottomTex = "rbxassetid://57928490",
  302. leftTex = "rbxassetid://57928490",
  303. rightTex = "rbxassetid://57928490"
  304. },
  305. Diamond_Block = {
  306. size = Vector3.new(2.6, 2.6, 2.6),
  307. frontTex = "rbxassetid://56749955",
  308. backTex = "rbxassetid://56749955",
  309. topTex = "rbxassetid://56749955",
  310. bottomTex = "rbxassetid://56749955",
  311. leftTex = "rbxassetid://56749955",
  312. rightTex = "rbxassetid://56749955"
  313. },
  314. Wood_Planks = {
  315. size = Vector3.new(2.6, 2.6, 2.6),
  316. frontTex = "rbxassetid://346201871",
  317. backTex = "rbxassetid://346201871",
  318. topTex = "rbxassetid://346201871",
  319. bottomTex = "rbxassetid://346201871",
  320. leftTex = "rbxassetid://346201871",
  321. rightTex = "rbxassetid://346201871"
  322. },
  323. Oak_Log = {
  324. size = Vector3.new(2.6, 2.6, 2.6),
  325. frontTex = "rbxassetid://310831812",
  326. backTex = "rbxassetid://310831812",
  327. topTex = "rbxassetid://152538557",
  328. bottomTex = "rbxassetid://152538557",
  329. leftTex = "rbxassetid://310831812",
  330. rightTex = "rbxassetid://310831812"
  331. }
  332. }
  333. if player then
  334. local char = player.Character
  335. if char then
  336. for _,cM in pairs(char:GetChildren()) do
  337. if cM.ClassName == "CharacterMesh" then cM:Destroy() end
  338. end
  339.  
  340. --[]
  341. local gui = player.PlayerGui:FindFirstChild("ToolBar") or Instance.new("ScreenGui", player.PlayerGui)
  342. gui.Name = "ToolBar"
  343.  
  344. makeSquare(UDim2.new(0.5, -166, 1, -111), UDim2.new(0, 364, 0, 44),
  345. Color3.new(0/255, 0/255, 0/255), 0, gui)
  346.  
  347. local blocks = {"Dirt", "Grass", "Stone", "Diamond_Ore", "Diamond_Block", "Wood_Planks", "Oak_Log"}
  348. for i = 1, 9 do
  349. if toolBar[blocks[i]] ~= nil then
  350. putToolBarSlot(UDim2.new(0.5, -160 + ((i-1)*40), 1, -105), toolBar[blocks[i]].frontTex)
  351. else
  352. putToolBarSlot(UDim2.new(0.5, -160 + ((i-1)*40), 1, -105), "")
  353. end
  354. end
  355.  
  356. local humRootPart = char:WaitForChild("HumanoidRootPart")
  357. local head = char:WaitForChild("Head")
  358. local torso = char:WaitForChild("Torso")
  359. local lArm = char:WaitForChild("Left Arm")
  360. local rArm = char:WaitForChild("Right Arm")
  361. local lLeg = char:WaitForChild("Left Leg")
  362. local rLeg = char:WaitForChild("Right Leg")
  363.  
  364. head.Size = Vector3.new(1.3, 1.3, 1.3)
  365. putTexture(head, "rbxassetid://38738031", "rbxassetid://36047330",
  366. "rbxassetid://36047341", "rbxassetid://36047347",
  367. "rbxassetid://36047323", "rbxassetid://36047315", "Decal")
  368. head:WaitForChild("Mesh"):Destroy()
  369. head:WaitForChild("face"):Destroy()
  370.  
  371. torso.Size = Vector3.new(1.3, 1.95, 0.65)
  372. putTexture(torso, "rbxassetid://38934753", "rbxassetid://38934731",
  373. "rbxassetid://38934780", "rbxassetid://38934740",
  374. "rbxassetid://38934762", "rbxassetid://38934762", "Decal")
  375.  
  376. lArm.Size = Vector3.new(0.65, 1.95, 0.65)
  377. putTexture(lArm, "rbxassetid://38934581", "rbxassetid://38934560",
  378. "rbxassetid://38934613", "rbxassetid://38934568",
  379. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  380.  
  381. rArm.Size = Vector3.new(0.65, 1.95, 0.65)
  382. putTexture(rArm, "rbxassetid://38934560", "rbxassetid://38934581",
  383. "rbxassetid://38934613", "rbxassetid://38934568",
  384. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  385.  
  386. lLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  387. putTexture(lLeg, "rbxassetid://38936226", "rbxassetid://38936209",
  388. "rbxassetid://38934719", "rbxassetid://38934712",
  389. "rbxassetid://38936255", "rbxassetid://38936242", "Decal")
  390.  
  391. rLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  392. putTexture(rLeg, "rbxassetid://38936209", "rbxassetid://38936226",
  393. "rbxassetid://38934719", "rbxassetid://38934712",
  394. "rbxassetid://38936242", "rbxassetid://38936255", "Decal")
  395.  
  396. char.Humanoid:ClearAllChildren()
  397. char.Animate:Remove()
  398.  
  399. -- now for the real stuff
  400. -- |
  401. -- |
  402. -- V
  403. Instance.new("BlockMesh", torso)
  404. Instance.new("BlockMesh", lArm)
  405. Instance.new("BlockMesh", rArm)
  406. Instance.new("BlockMesh", lLeg)
  407. Instance.new("BlockMesh", rLeg)
  408.  
  409. local camera = workspace.Camera
  410. local camPart = Instance.new("Part", camera)
  411. camPart.Size = Vector3.new(0, 0, 0)
  412. camPart.CFrame = camera.CFrame
  413. camPart.Transparency = 1
  414.  
  415. --[[local cameraHand = Instance.new("Part", camera)
  416. cameraHand.Size = Vector3.new(0.65, 1.95, 0.65)
  417. cameraHand.CanCollide = false
  418. cameraHand.Anchored = true
  419. cameraHand.Name = "CameraHand"
  420. putTexture(cameraHand, "rbxassetid://38934560", "rbxassetid://38934581",
  421. "rbxassetid://38934613", "rbxassetid://38934568",
  422. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  423.  
  424. local cameraHandWeld = Instance.new("Motor6D", camPart)
  425. cameraHandWeld.Part0 = camPart
  426. cameraHandWeld.Part1 = cameraHand
  427. cameraHandWeld.C0 = CFrame.new(5, 0, 0)
  428. ]]--
  429.  
  430. local humanoid = char:WaitForChild("Humanoid")
  431. humanoid.HipHeight = 0.3
  432.  
  433. local rootJoint = Instance.new("Motor6D", torso)
  434. rootJoint.Name = "RootJoint"
  435. rootJoint.Part0 = humRootPart
  436. rootJoint.Part1 = torso
  437. rootJoint.C1 = CFrame.new(0, 0.05, 0)
  438.  
  439. local neck = Instance.new("Motor6D", torso)
  440. neck.Name = "Neck"
  441. neck.Part0 = head
  442. neck.Part1 = torso
  443.  
  444. local lS = Instance.new("Motor6D", torso)
  445. lS.Name = "Left Shoulder"
  446. lS.Part0 = lArm
  447. lS.Part1 = torso
  448. lS.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  449. lS.C1 = CFrame.new(0.65, 0.975, 0)
  450.  
  451. local rS = Instance.new("Motor6D", torso)
  452. rS.Name = "Right Shoulder"
  453. rS.Part0 = rArm
  454. rS.Part1 = torso
  455. rS.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  456. rS.C1 = CFrame.new(-0.65, 0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  457.  
  458. local lH = Instance.new("Motor6D", torso)
  459. lH.Name = "Left Hip"
  460. lH.Part0 = lLeg
  461. lH.Part1 = torso
  462. lH.C0 = CFrame.new(0, 0.975, 0)
  463. lH.C1 = CFrame.new(0.325, -0.975, 0) * CFrame.Angles(0, 0, 0)
  464.  
  465. local rH = Instance.new("Motor6D", torso)
  466. rH.Name = "Right Hip"
  467. rH.Part0 = rLeg
  468. rH.Part1 = torso
  469. rH.C0 = CFrame.new(0, 0.975, 0)
  470. rH.C1 = CFrame.new(-0.325, -0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  471.  
  472. for _,p in pairs(char:GetChildren()) do
  473. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  474. local hit = Instance.new("Part", char)
  475. hit.Name = "DamagePart"
  476. hit.BrickColor = BrickColor.new("Bright red")
  477. hit.Material = "SmoothPlastic"
  478. hit.Transparency = 1
  479. hit.Size = Vector3.new(p.Size.X + 0.05, p.Size.Y + 0.05, p.Size.Z + 0.05)
  480. hit.CanCollide = false
  481. weldTo(hit, p)
  482. end
  483. end
  484.  
  485. local ticks = 0
  486. local times = 0
  487.  
  488. local walkAnim = 0
  489. local increaseWalkAnim = 1
  490.  
  491. local idleAnimRotX = 0
  492. local idleAnimRotZ = 0
  493. local sneaking = 0
  494.  
  495. local RS = game:GetService("RunService").RenderStepped
  496. local Mouse = player:GetMouse()
  497.  
  498. local oldHP = humanoid.Health
  499. local damageTime = 0
  500.  
  501. local punchRotX = 0
  502. local punchRotY = 0
  503. local punchRotZ = 0
  504. local punchSpeed = 0
  505. local punching = 0
  506. local selectedBlock = 8
  507. local punchEnded = 1
  508. local itemOnHand = nil
  509.  
  510. local handItem = Instance.new("Part", char)
  511. handItem.Name = "HandItem"
  512. handItem.Size = Vector3.new(0.52, 0.52, 0.52)
  513. handItem.Transparency = 1
  514. handItem.CanCollide = false
  515.  
  516. local handItemWeld = Instance.new("Weld", char)
  517. handItemWeld.Part0 = handItem
  518. handItemWeld.Part1 = lArm
  519. handItemWeld.C1 = CFrame.new(0, -0.9, -0.6) * CFrame.Angles(math.rad(-10), math.rad(45), 0)
  520.  
  521. local sound = Instance.new("Sound", char)
  522. sound.Name = "Hurt"
  523. sound.Volume = 10
  524. sound.SoundId = "rbxassetid://535690488"
  525.  
  526. local facesToResize = {"Front", "Back", "Left", "Right", "Bottom", "Top"}
  527. Mouse.Button1Down:connect(function()
  528. if punchEnded == 1 then punching = 1 end
  529. if Mouse.Target then
  530. if getDistance(head.CFrame.p, Mouse.Hit.p) <= 10.4 then
  531. local humanoid = Mouse.Target.Parent:FindFirstChild("Humanoid")
  532. if humanoid then
  533. humanoid.Health = humanoid.Health - 10
  534. local parts = Mouse.Target.Parent:GetChildren()
  535. for _,p in pairs(parts) do
  536. if p.ClassName == "Part" then
  537. p.Velocity = Vector3.new(p.Velocity.X + (head.CFrame.lookVector.X * 18), p.Velocity.Y + (head.CFrame.lookVector.Y * 18) + 8, p.Velocity.Z + (head.CFrame.lookVector.Z * 18))
  538. end
  539. end
  540. return
  541. end
  542. local x = Mouse.Target.CFrame.p.X
  543. local y = Mouse.Target.CFrame.p.Y
  544. local z = Mouse.Target.CFrame.p.Z
  545. if Mouse.TargetSurface.Name == "Right" then x = x + 2.6 end
  546. if Mouse.TargetSurface.Name == "Left" then x = x - 2.6 end
  547. if Mouse.TargetSurface.Name == "Top" then y = y + 2.6 end
  548. if Mouse.TargetSurface.Name == "Bottom" then y = y - 2.6 end
  549. if Mouse.TargetSurface.Name == "Back" then z = z + 2.6 end
  550. if Mouse.TargetSurface.Name == "Front" then z = z - 2.6 end
  551. if Mouse.Target.Size.X > 2.6 or Mouse.Target.Size.Y > 2.6 or Mouse.Target.Size.Z > 2.6 then
  552. x = Mouse.Hit.p.X
  553. y = Mouse.Hit.p.Y
  554. z = Mouse.Hit.p.Z
  555. end
  556. -- local x = round(math.abs(mouseX)/2.6)*2.6
  557. -- local y = round(math.abs(mouseY)/2.6)*2.6
  558. -- local z = round(math.abs(mouseZ)/2.6)*2.6
  559. -- if Mouse.Hit.p.X < 0 then x = x * -1 end
  560. -- if Mouse.Hit.p.Y < 0 then y = y * -1 end
  561. -- if Mouse.Hit.p.Z < 0 then z = z * -1 end
  562. if selectedBlock == 0 then
  563. local blk = placeBlock(toolBar.Dirt, CFrame.new(x, y, z))
  564. for _,f in pairs(facesToResize) do
  565. blk:WaitForChild(f).StudsPerTileU = 2.6
  566. blk:WaitForChild(f).StudsPerTileV = 2.6
  567. end
  568. elseif selectedBlock == 1 then
  569. local blk = placeBlock(toolBar.Grass, CFrame.new(x, y, z))
  570. for _,f in pairs(facesToResize) do
  571. blk:WaitForChild(f).StudsPerTileU = 2.6
  572. blk:WaitForChild(f).StudsPerTileV = 2.6
  573. end
  574. elseif selectedBlock == 2 then
  575. local blk = placeBlock(toolBar.Stone, CFrame.new(x, y, z))
  576. for _,f in pairs(facesToResize) do
  577. blk:WaitForChild(f).StudsPerTileU = 2.6
  578. blk:WaitForChild(f).StudsPerTileV = 2.6
  579. end
  580. elseif selectedBlock == 3 then
  581. local blk = placeBlock(toolBar.Diamond_Ore, CFrame.new(x, y, z))
  582. for _,f in pairs(facesToResize) do
  583. blk:WaitForChild(f).StudsPerTileU = 2.6
  584. blk:WaitForChild(f).StudsPerTileV = 2.6
  585. end
  586. elseif selectedBlock == 4 then
  587. local blk = placeBlock(toolBar.Diamond_Block, CFrame.new(x, y, z))
  588. for _,f in pairs(facesToResize) do
  589. blk:WaitForChild(f).StudsPerTileU = 2.6
  590. blk:WaitForChild(f).StudsPerTileV = 2.6
  591. end
  592. elseif selectedBlock == 5 then
  593. local blk = placeBlock(toolBar.Wood_Planks, CFrame.new(x, y, z))
  594. for _,f in pairs(facesToResize) do
  595. blk:WaitForChild(f).StudsPerTileU = 2.6
  596. blk:WaitForChild(f).StudsPerTileV = 2.6
  597. end
  598. elseif selectedBlock == 6 then
  599. local blk = placeBlock(toolBar.Oak_Log, CFrame.new(x, y, z))
  600. for _,f in pairs(facesToResize) do
  601. blk:WaitForChild(f).StudsPerTileU = 2.6
  602. blk:WaitForChild(f).StudsPerTileV = 2.6
  603. end
  604. elseif selectedBlock == 7 or selectedBlock == 8 then
  605. if Mouse.Target.Size.X <= 10 and Mouse.Target.Size.Y <= 10 and Mouse.Target.Size.Z <= 10 then
  606. Mouse.Target.Parent = nil
  607. end
  608. end
  609. end
  610. end
  611. end)
  612.  
  613. local hasItemOnHand = 0
  614. local hi = 0
  615. -- selection thingy
  616. local selectLabel = Instance.new("TextLabel", gui)
  617. selectLabel.Size = UDim2.new(0, 32, 0, 32)
  618. selectLabel.Position = UDim2.new(0.5, -160 + (selectedBlock*40), 1, -105)
  619. selectLabel.BackgroundTransparency = 0.5
  620. selectLabel.BackgroundColor3 = Color3.new(1, 1, 1)
  621. selectLabel.BorderSizePixel = 0
  622. selectLabel.Text = ""
  623. selectLabel.ZIndex = 3
  624. --
  625. Mouse.KeyDown:connect(function(key)
  626. if key == "q" then
  627. sneaking = 1
  628. humanoid.WalkSpeed = humanoid.WalkSpeed / 2
  629. rootJoint.C1 = CFrame.new(0, 0.325, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  630. lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45), 0, 0)
  631. rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  632. --print("Sneaking...")
  633. end
  634. if key == "8" then
  635. selectedBlock = 7
  636. itemOnHand = nil
  637. for _,d in pairs(handItem:GetChildren()) do
  638. d:Destroy()
  639. end
  640. if hasItemOnHand == 1 then hi = 1 end
  641. end
  642. if key == "9" then
  643. selectedBlock = 8
  644. itemOnHand = nil
  645. for _,d in pairs(handItem:GetChildren()) do
  646. d:Destroy()
  647. end
  648. if hasItemOnHand == 1 then hi = 1 end
  649. end
  650. if key == "1" then
  651. selectedBlock = 0
  652. itemOnHand = toolBar.Dirt
  653. for _,d in pairs(handItem:GetChildren()) do
  654. d:Destroy()
  655. end
  656. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  657. itemOnHand.topTex, itemOnHand.bottomTex,
  658. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  659. for _,f in pairs(facesToResize) do
  660. handItem:WaitForChild(f).StudsPerTileU = 0.52
  661. handItem:WaitForChild(f).StudsPerTileV = 0.52
  662. end
  663. end
  664. if key == "2" then
  665. selectedBlock = 1
  666. itemOnHand = toolBar.Grass
  667. for _,d in pairs(handItem:GetChildren()) do
  668. d:Destroy()
  669. end
  670. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  671. itemOnHand.topTex, itemOnHand.bottomTex,
  672. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  673. for _,f in pairs(facesToResize) do
  674. handItem:WaitForChild(f).StudsPerTileU = 0.52
  675. handItem:WaitForChild(f).StudsPerTileV = 0.52
  676. end
  677. end
  678. if key == "3" then
  679. selectedBlock = 2
  680. itemOnHand = toolBar.Stone
  681. for _,d in pairs(handItem:GetChildren()) do
  682. d:Destroy()
  683. end
  684. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  685. itemOnHand.topTex, itemOnHand.bottomTex,
  686. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  687. for _,f in pairs(facesToResize) do
  688. handItem:WaitForChild(f).StudsPerTileU = 0.52
  689. handItem:WaitForChild(f).StudsPerTileV = 0.52
  690. end
  691. end
  692. if key == "4" then
  693. selectedBlock = 3
  694. itemOnHand = toolBar.Diamond_Ore
  695. for _,d in pairs(handItem:GetChildren()) do
  696. d:Destroy()
  697. end
  698. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  699. itemOnHand.topTex, itemOnHand.bottomTex,
  700. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  701. for _,f in pairs(facesToResize) do
  702. handItem:WaitForChild(f).StudsPerTileU = 0.52
  703. handItem:WaitForChild(f).StudsPerTileV = 0.52
  704. end
  705. end
  706. if key == "5" then
  707. selectedBlock = 4
  708. itemOnHand = toolBar.Diamond_Block
  709. for _,d in pairs(handItem:GetChildren()) do
  710. d:Destroy()
  711. end
  712. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  713. itemOnHand.topTex, itemOnHand.bottomTex,
  714. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  715. for _,f in pairs(facesToResize) do
  716. handItem:WaitForChild(f).StudsPerTileU = 0.52
  717. handItem:WaitForChild(f).StudsPerTileV = 0.52
  718. end
  719. end
  720. if key == "6" then
  721. selectedBlock = 5
  722. itemOnHand = toolBar.Wood_Planks
  723. for _,d in pairs(handItem:GetChildren()) do
  724. d:Destroy()
  725. end
  726. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  727. itemOnHand.topTex, itemOnHand.bottomTex,
  728. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  729. for _,f in pairs(facesToResize) do
  730. handItem:WaitForChild(f).StudsPerTileU = 0.52
  731. handItem:WaitForChild(f).StudsPerTileV = 0.52
  732. end
  733. end
  734. if key == "7" then
  735. selectedBlock = 6
  736. itemOnHand = toolBar.Oak_Log
  737. for _,d in pairs(handItem:GetChildren()) do
  738. d:Destroy()
  739. end
  740. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  741. itemOnHand.topTex, itemOnHand.bottomTex,
  742. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  743. for _,f in pairs(facesToResize) do
  744. handItem:WaitForChild(f).StudsPerTileU = 0.52
  745. handItem:WaitForChild(f).StudsPerTileV = 0.52
  746. end
  747. end
  748. if (key == "0" or key == "1" or key == "2"
  749. or key == "3" or key == "4" or key == "5"
  750. or key == "6" or key == "7") and hasItemOnHand == 0 then hi = 1 end
  751. selectLabel.Position = UDim2.new(0.5, -160 + ((selectedBlock)*40), 1, -105)
  752. end)
  753.  
  754. Mouse.KeyUp:connect(function(key)
  755. if key == "q" then
  756. sneaking = 0
  757. humanoid.WalkSpeed = humanoid.WalkSpeed * 2
  758. rootJoint.C1 = CFrame.new(0, 0.05, 0) * CFrame.Angles(0, 0, 0)
  759. lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(0, 0, 0)
  760. rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(0, 0, 0)
  761. --print("Stopped sneaking...")
  762. end
  763. end)
  764.  
  765. while RS:wait() do
  766. if itemOnHand ~= nil then
  767. hasItemOnHand = 1
  768. handItem.Transparency = 0
  769. else
  770. hasItemOnHand = 0
  771. handItem.Transparency = 1
  772. end
  773. if humanoid.Health < oldHP then
  774. damageTime = 60
  775. sound:Play()
  776. end
  777. oldHP = humanoid.Health
  778. if damageTime > 0 and humanoid.Health > 0 then
  779. for _,p in pairs(char:GetChildren()) do
  780. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  781. if p.Name == "DamagePart" then
  782. p.Transparency = 0.5
  783. end
  784. end
  785. end
  786. damageTime = damageTime - 2
  787. if damageTime <= 0 then
  788. for _,p in pairs(char:GetChildren()) do
  789. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  790. if p.Name == "DamagePart" then
  791. p.Transparency = 1
  792. end
  793. end
  794. end
  795. end
  796. end
  797. camPart.CFrame = camera.CFrame
  798. neck.C1 = CFrame.new(0, 0.975, 0) * CFrame.fromEulerAnglesXYZ(math.rad(sneaking*45), math.rad(camPart.Orientation.Y - torso.Orientation.Y), 0)
  799. neck.C0 = CFrame.new(0, -0.65, 0) * CFrame.Angles(-math.rad(camPart.Orientation.X - torso.Orientation.X - (sneaking*45)), 0, 0)
  800.  
  801. if getMagnitudeXZ(torso.Velocity) > 1 then
  802. if walkAnim >= 1 then
  803. increaseWalkAnim = -1
  804. elseif walkAnim <= -1 then
  805. increaseWalkAnim = 1
  806. end
  807. walkAnim = walkAnim + (increaseWalkAnim/(10+(sneaking*20)))
  808. else
  809. walkAnim = 0
  810. end
  811.  
  812. --lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45), 0, 0)
  813. --rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  814. lH.C0 = lH.C0:lerp(CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45) + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)), 0, 0), 0.1)
  815. rH.C0 = rH.C0:lerp(CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45) + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)), 0, 0), 0.1)
  816. --
  817. --rootJoint.C0 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
  818. --print(math.abs(head.Orientation.Y) - math.abs(humRootPart.Orientation.Y))
  819. --if (head.Orientation.Y * 2) - (head.Orientation.Y + torso.Orientation.Y) > 45 then
  820. --humRootPart.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(-45 + head.Orientation.Y), 0)
  821. --print("-45")
  822. --end
  823. --if (head.Orientation.Y * 2) - (head.Orientation.Y + torso.Orientation.Y) < -45 then
  824. --humRootPart.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(45 + head.Orientation.Y), 0)
  825. --print("45")
  826. --end
  827.  
  828. --move these arms
  829. rootJoint.C1 = rootJoint.C1:lerp(CFrame.new(0, 0.325, 0) * CFrame.Angles(math.rad(sneaking*45), math.rad(punchRotY), 0), 0.2)
  830.  
  831. lS.C0 = lS.C0:lerp(CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(idleAnimRotX/20 + math.rad(-hasItemOnHand*10) + math.rad(punchRotX) + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)), 0, math.rad(punchRotZ) + idleAnimRotZ/20), 0.025+(math.min(1, getMagnitudeXZ(torso.Velocity))/12) + divide(punchSpeed, 6) + hi)
  832. rS.C0 = rS.C0:lerp(CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(idleAnimRotX/20 + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)), 0, idleAnimRotZ/20), 0.025+(math.min(1, getMagnitudeXZ(torso.Velocity))/12))
  833. if punching == 1 and punchEnded == 1 then
  834. punching = 0
  835. --print("steve uses punch!!")
  836. local coPunch = coroutine.wrap(function()
  837. punchEnded = 0
  838. punchSpeed = 1
  839. punchRotX = -60
  840. punchRotY = -8
  841. punchRotZ = -35
  842. wait(0.075)
  843. punchSpeed = 1
  844. punchRotX = -75
  845. punchRotY = 8
  846. punchRotZ = 40
  847. wait(0.075)
  848. punchSpeed = 1
  849. punchRotX = -20
  850. punchRotZ = 40
  851. wait(0.075)
  852. punchSpeed = 3.5
  853. punchRotX = 0
  854. punchRotY = 0
  855. punchRotZ = 0
  856. punchEnded = 1
  857. wait(0.06)
  858. punchSpeed = 0
  859. end)
  860. coPunch()
  861. end
  862. if ticks > 20 then
  863. ticks = 0
  864. if times == 0 then
  865. times = times + 1
  866. idleAnimRotX = -1
  867. idleAnimRotZ = 0
  868. elseif times == 1 then
  869. times = times + 1
  870. idleAnimRotX = -0.75
  871. idleAnimRotZ = -0.75
  872. elseif times == 2 then
  873. times = times + 1
  874. idleAnimRotX = 0
  875. idleAnimRotZ = -1
  876. elseif times == 3 then
  877. times = times + 1
  878. idleAnimRotX = 0.75
  879. idleAnimRotZ = -0.75
  880. --idleAnimRotX = 0.75
  881. --idleAnimRotZ = -0
  882. elseif times == 4 then
  883. times = times + 1
  884. idleAnimRotX = 1
  885. idleAnimRotZ = 0
  886. --idleAnimRotX = 1
  887. --idleAnimRotZ = 0
  888. elseif times == 5 then
  889. times = times + 1
  890. idleAnimRotX = 0.75
  891. idleAnimRotZ = 0.75
  892. elseif times == 6 then
  893. times = times + 1
  894. idleAnimRotX = 0
  895. idleAnimRotZ = 1
  896. elseif times == 7 then
  897. times = 0
  898. idleAnimRotX = -0.75
  899. idleAnimRotZ = 0.75
  900. end
  901. end
  902. if hi == 1 then hi = 0 end
  903. ticks = ticks + 1
  904. end
  905. end
  906. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement