-----------------

minecraft script only for me

Feb 1st, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.31 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. local targetName = game.Players.LocalPlayer.Name
  153. local player = game.Players:FindFirstChild(targetName)
  154. function putTexture(part, frontF, backF, topF, bottomF, leftF, rightF, className)
  155. local faces = {"Front", "Back", "Top", "Bottom", "Left", "Right"}
  156. for i,f in pairs(faces) do
  157. local decal = Instance.new(className, part)
  158. if i == 1 then decal.Texture = frontF decal.Name = f end
  159. if i == 2 then decal.Texture = backF or frontF decal.Name = f end
  160. if i == 3 then decal.Texture = topF or frontF decal.Name = f end
  161. if i == 4 then decal.Texture = bottomF or frontF decal.Name = f end
  162. if i == 5 then decal.Texture = leftF or frontF decal.Name = f end
  163. if i == 6 then decal.Texture = rightF or frontF decal.Name = f end
  164. decal.Face = f
  165. end
  166. return part
  167. end
  168. function makeSquare(position, size, color, transparency, parent)
  169. local label = Instance.new("TextLabel", parent)
  170. label.Text = ""
  171. label.BorderSizePixel = 0
  172. label.BackgroundTransparency = transparency
  173. label.Position = position
  174. label.Size = size
  175. label.BackgroundColor3 = color
  176. end
  177. function putToolBarSlot(position, image)
  178. local playerGui = player:FindFirstChild("PlayerGui")
  179. if playerGui then
  180. local gui = playerGui:FindFirstChild("ToolBar") or Instance.new("ScreenGui", playerGui)
  181. gui.Name = "ToolBar"
  182. local slot = Instance.new("ImageLabel", gui)
  183. slot.Position = position
  184. slot.Size = UDim2.new(0, 32, 0, 32)
  185. slot.BackgroundTransparency = 1
  186. slot.ImageTransparency = 0
  187. slot.Image = image
  188. slot.ZIndex = 2
  189.  
  190. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 32, 0, 32),
  191. Color3.new(95/255, 89/255, 76/255), 0, slot)
  192. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 2, 0, 32),
  193. Color3.new(0/255, 0/255, 0/255), 0.5, slot)
  194. makeSquare(UDim2.new(0, 2, 0, 0), UDim2.new(0, 30, 0, 2),
  195. Color3.new(0/255, 0/255, 0/255), 0.5, slot)
  196. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 36, 0, 2),
  197. Color3.new(106/255, 106/255, 106/255), 0, slot)
  198. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 2, 0, 36),
  199. Color3.new(106/255, 106/255, 106/255), 0, slot)
  200. makeSquare(UDim2.new(0, 0, 0, 32), UDim2.new(0, 34, 0, 2),
  201. Color3.new(130/255, 130/255, 130/255), 0, slot)
  202. makeSquare(UDim2.new(0, 32, 0, 0), UDim2.new(0, 2, 0, 34),
  203. Color3.new(130/255, 130/255, 130/255), 0, slot)
  204. makeSquare(UDim2.new(0, -4, 0, -2), UDim2.new(0, 2, 0, 38),
  205. Color3.new(130/255, 130/255, 130/255), 0, slot)
  206. makeSquare(UDim2.new(0, 34, 0, -2), UDim2.new(0, 2, 0, 36),
  207. Color3.new(106/255, 106/255, 106/255), 0, slot)
  208. makeSquare(UDim2.new(0, -2, 0, 34), UDim2.new(0, 38, 0, 2),
  209. Color3.new(106/255, 106/255, 106/255), 0, slot)
  210. makeSquare(UDim2.new(0, -4, 0, -4), UDim2.new(0, 40, 0, 2),
  211. Color3.new(156/255, 156/255, 156/255), 0, slot)
  212. end
  213. end
  214. function divide(x, d)
  215. if x ~= 0 and d ~= 0 then
  216. return x/d
  217. else
  218. return x
  219. end
  220. end -- so it doesn't divide by zero
  221. function getDistance(v1, v2)
  222. return math.abs((Vector3.new(math.abs(v2.X - v1.X), math.abs(v2.Y - v1.Y), math.abs(v2.Z - v1.Z))).Magnitude)
  223. end
  224. function round(x)
  225. if x%2 ~= 0.5 then
  226. return math.floor(x+0.5)
  227. end
  228. return x-0.5
  229. end
  230. function weldTo(part1, part2)
  231. local weld = Instance.new("Weld", part1)
  232. weld.Part0 = part1
  233. weld.Part1 = part2
  234. end
  235. function getMagnitudeXZ(velocity)
  236. return math.abs(velocity.X) + math.abs(velocity.Z)
  237. end
  238. function placeBlock(block, cFPos)
  239. local blockPlaced = Instance.new("Part", workspace)
  240. blockPlaced.Material = "Fabric"
  241. blockPlaced.Anchored = true
  242. blockPlaced.Size = block.size
  243. blockPlaced.CFrame = cFPos
  244. putTexture(blockPlaced, block.frontTex, block.backTex,
  245. block.topTex, block.bottomTex, block.leftTex, block.rightTex, "Texture")
  246. return blockPlaced
  247. end
  248. local toolBar = {
  249. Dirt = {
  250. size = Vector3.new(2.6, 2.6, 2.6),
  251. frontTex = "rbxassetid://179655033",
  252. backTex = "rbxassetid://179655033",
  253. topTex = "rbxassetid://179655033",
  254. bottomTex = "rbxassetid://179655033",
  255. leftTex = "rbxassetid://179655033",
  256. rightTex = "rbxassetid://179655033"
  257. },
  258. Grass = {
  259. size = Vector3.new(2.6, 2.6, 2.6),
  260. frontTex = "rbxassetid://96430337",
  261. backTex = "rbxassetid://96430337",
  262. topTex = "rbxassetid://96430265",
  263. bottomTex = "rbxassetid://179655033",
  264. leftTex = "rbxassetid://96430337",
  265. rightTex = "rbxassetid://96430337"
  266. },
  267. Stone = {
  268. size = Vector3.new(2.6, 2.6, 2.6),
  269. frontTex = "rbxassetid://75880927",
  270. backTex = "rbxassetid://75880927",
  271. topTex = "rbxassetid://75880927",
  272. bottomTex = "rbxassetid://75880927",
  273. leftTex = "rbxassetid://75880927",
  274. rightTex = "rbxassetid://75880927"
  275. },
  276. Diamond_Ore = {
  277. size = Vector3.new(2.6, 2.6, 2.6),
  278. frontTex = "rbxassetid://57928490",
  279. backTex = "rbxassetid://57928490",
  280. topTex = "rbxassetid://57928490",
  281. bottomTex = "rbxassetid://57928490",
  282. leftTex = "rbxassetid://57928490",
  283. rightTex = "rbxassetid://57928490"
  284. },
  285. Diamond_Block = {
  286. size = Vector3.new(2.6, 2.6, 2.6),
  287. frontTex = "rbxassetid://56749955",
  288. backTex = "rbxassetid://56749955",
  289. topTex = "rbxassetid://56749955",
  290. bottomTex = "rbxassetid://56749955",
  291. leftTex = "rbxassetid://56749955",
  292. rightTex = "rbxassetid://56749955"
  293. },
  294. Wood_Planks = {
  295. size = Vector3.new(2.6, 2.6, 2.6),
  296. frontTex = "rbxassetid://346201871",
  297. backTex = "rbxassetid://346201871",
  298. topTex = "rbxassetid://346201871",
  299. bottomTex = "rbxassetid://346201871",
  300. leftTex = "rbxassetid://346201871",
  301. rightTex = "rbxassetid://346201871"
  302. },
  303. Oak_Log = {
  304. size = Vector3.new(2.6, 2.6, 2.6),
  305. frontTex = "rbxassetid://310831812",
  306. backTex = "rbxassetid://310831812",
  307. topTex = "rbxassetid://152538557",
  308. bottomTex = "rbxassetid://152538557",
  309. leftTex = "rbxassetid://310831812",
  310. rightTex = "rbxassetid://310831812"
  311. }
  312. }
  313. if player then
  314. local char = player.Character
  315. if char then
  316. for _,cM in pairs(char:GetChildren()) do
  317. if cM.ClassName == "CharacterMesh" then cM:Destroy() end
  318. end
  319.  
  320. --[]
  321. local gui = player.PlayerGui:FindFirstChild("ToolBar") or Instance.new("ScreenGui", player.PlayerGui)
  322. gui.Name = "ToolBar"
  323.  
  324. makeSquare(UDim2.new(0.5, -166, 1, -111), UDim2.new(0, 364, 0, 44),
  325. Color3.new(0/255, 0/255, 0/255), 0, gui)
  326.  
  327. local blocks = {"Dirt", "Grass", "Stone", "Diamond_Ore", "Diamond_Block", "Wood_Planks", "Oak_Log"}
  328. for i = 1, 9 do
  329. if toolBar[blocks[i]] ~= nil then
  330. putToolBarSlot(UDim2.new(0.5, -160 + ((i-1)*40), 1, -105), toolBar[blocks[i]].frontTex)
  331. else
  332. putToolBarSlot(UDim2.new(0.5, -160 + ((i-1)*40), 1, -105), "")
  333. end
  334. end
  335.  
  336. local humRootPart = char:WaitForChild("HumanoidRootPart")
  337. local head = char:WaitForChild("Head")
  338. local torso = char:WaitForChild("Torso")
  339. local lArm = char:WaitForChild("Left Arm")
  340. local rArm = char:WaitForChild("Right Arm")
  341. local lLeg = char:WaitForChild("Left Leg")
  342. local rLeg = char:WaitForChild("Right Leg")
  343.  
  344. head.Size = Vector3.new(1.3, 1.3, 1.3)
  345. putTexture(head, "rbxassetid://38738031", "rbxassetid://36047330",
  346. "rbxassetid://36047341", "rbxassetid://36047347",
  347. "rbxassetid://36047323", "rbxassetid://36047315", "Decal")
  348. head:WaitForChild("Mesh"):Destroy()
  349. head:WaitForChild("face"):Destroy()
  350.  
  351. torso.Size = Vector3.new(1.3, 1.95, 0.65)
  352. putTexture(torso, "rbxassetid://38934753", "rbxassetid://38934731",
  353. "rbxassetid://38934780", "rbxassetid://38934740",
  354. "rbxassetid://38934762", "rbxassetid://38934762", "Decal")
  355.  
  356. lArm.Size = Vector3.new(0.65, 1.95, 0.65)
  357. putTexture(lArm, "rbxassetid://38934581", "rbxassetid://38934560",
  358. "rbxassetid://38934613", "rbxassetid://38934568",
  359. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  360.  
  361. rArm.Size = Vector3.new(0.65, 1.95, 0.65)
  362. putTexture(rArm, "rbxassetid://38934560", "rbxassetid://38934581",
  363. "rbxassetid://38934613", "rbxassetid://38934568",
  364. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  365.  
  366. lLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  367. putTexture(lLeg, "rbxassetid://38936226", "rbxassetid://38936209",
  368. "rbxassetid://38934719", "rbxassetid://38934712",
  369. "rbxassetid://38936255", "rbxassetid://38936242", "Decal")
  370.  
  371. rLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  372. putTexture(rLeg, "rbxassetid://38936209", "rbxassetid://38936226",
  373. "rbxassetid://38934719", "rbxassetid://38934712",
  374. "rbxassetid://38936242", "rbxassetid://38936255", "Decal")
  375.  
  376. char.Humanoid:ClearAllChildren()
  377. char.Animate:Remove()
  378.  
  379. -- now for the real stuff
  380. -- |
  381. -- |
  382. -- V
  383. Instance.new("BlockMesh", torso)
  384. Instance.new("BlockMesh", lArm)
  385. Instance.new("BlockMesh", rArm)
  386. Instance.new("BlockMesh", lLeg)
  387. Instance.new("BlockMesh", rLeg)
  388.  
  389. local camera = workspace.Camera
  390. local camPart = Instance.new("Part", camera)
  391. camPart.Size = Vector3.new(0, 0, 0)
  392. camPart.CFrame = camera.CFrame
  393. camPart.Transparency = 1
  394.  
  395. --[[local cameraHand = Instance.new("Part", camera)
  396. cameraHand.Size = Vector3.new(0.65, 1.95, 0.65)
  397. cameraHand.CanCollide = false
  398. cameraHand.Anchored = true
  399. cameraHand.Name = "CameraHand"
  400. putTexture(cameraHand, "rbxassetid://38934560", "rbxassetid://38934581",
  401. "rbxassetid://38934613", "rbxassetid://38934568",
  402. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  403.  
  404. local cameraHandWeld = Instance.new("Motor6D", camPart)
  405. cameraHandWeld.Part0 = camPart
  406. cameraHandWeld.Part1 = cameraHand
  407. cameraHandWeld.C0 = CFrame.new(5, 0, 0)
  408. ]]--
  409.  
  410. local humanoid = char:WaitForChild("Humanoid")
  411. humanoid.HipHeight = 0.3
  412.  
  413. local rootJoint = Instance.new("Motor6D", torso)
  414. rootJoint.Name = "RootJoint"
  415. rootJoint.Part0 = humRootPart
  416. rootJoint.Part1 = torso
  417. rootJoint.C1 = CFrame.new(0, 0.05, 0)
  418.  
  419. local neck = Instance.new("Motor6D", torso)
  420. neck.Name = "Neck"
  421. neck.Part0 = head
  422. neck.Part1 = torso
  423.  
  424. local lS = Instance.new("Motor6D", torso)
  425. lS.Name = "Left Shoulder"
  426. lS.Part0 = lArm
  427. lS.Part1 = torso
  428. lS.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  429. lS.C1 = CFrame.new(0.65, 0.975, 0)
  430.  
  431. local rS = Instance.new("Motor6D", torso)
  432. rS.Name = "Right Shoulder"
  433. rS.Part0 = rArm
  434. rS.Part1 = torso
  435. rS.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  436. rS.C1 = CFrame.new(-0.65, 0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  437.  
  438. local lH = Instance.new("Motor6D", torso)
  439. lH.Name = "Left Hip"
  440. lH.Part0 = lLeg
  441. lH.Part1 = torso
  442. lH.C0 = CFrame.new(0, 0.975, 0)
  443. lH.C1 = CFrame.new(0.325, -0.975, 0) * CFrame.Angles(0, 0, 0)
  444.  
  445. local rH = Instance.new("Motor6D", torso)
  446. rH.Name = "Right Hip"
  447. rH.Part0 = rLeg
  448. rH.Part1 = torso
  449. rH.C0 = CFrame.new(0, 0.975, 0)
  450. rH.C1 = CFrame.new(-0.325, -0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  451.  
  452. for _,p in pairs(char:GetChildren()) do
  453. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  454. local hit = Instance.new("Part", char)
  455. hit.Name = "DamagePart"
  456. hit.BrickColor = BrickColor.new("Bright red")
  457. hit.Material = "SmoothPlastic"
  458. hit.Transparency = 1
  459. hit.Size = Vector3.new(p.Size.X + 0.05, p.Size.Y + 0.05, p.Size.Z + 0.05)
  460. hit.CanCollide = false
  461. weldTo(hit, p)
  462. end
  463. end
  464.  
  465. local ticks = 0
  466. local times = 0
  467.  
  468. local walkAnim = 0
  469. local increaseWalkAnim = 1
  470.  
  471. local idleAnimRotX = 0
  472. local idleAnimRotZ = 0
  473. local sneaking = 0
  474.  
  475. local RS = game:GetService("RunService").RenderStepped
  476. local Mouse = player:GetMouse()
  477.  
  478. local oldHP = humanoid.Health
  479. local damageTime = 0
  480.  
  481. local punchRotX = 0
  482. local punchRotY = 0
  483. local punchRotZ = 0
  484. local punchSpeed = 0
  485. local punching = 0
  486. local selectedBlock = 8
  487. local punchEnded = 1
  488. local itemOnHand = nil
  489.  
  490. local handItem = Instance.new("Part", char)
  491. handItem.Name = "HandItem"
  492. handItem.Size = Vector3.new(0.52, 0.52, 0.52)
  493. handItem.Transparency = 1
  494. handItem.CanCollide = false
  495.  
  496. local handItemWeld = Instance.new("Weld", char)
  497. handItemWeld.Part0 = handItem
  498. handItemWeld.Part1 = lArm
  499. handItemWeld.C1 = CFrame.new(0, -0.9, -0.6) * CFrame.Angles(math.rad(-10), math.rad(45), 0)
  500.  
  501. local sound = Instance.new("Sound", char)
  502. sound.Name = "Hurt"
  503. sound.Volume = 10
  504. sound.SoundId = "rbxassetid://535690488"
  505.  
  506. local facesToResize = {"Front", "Back", "Left", "Right", "Bottom", "Top"}
  507. Mouse.Button1Down:connect(function()
  508. if punchEnded == 1 then punching = 1 end
  509. if Mouse.Target then
  510. if getDistance(head.CFrame.p, Mouse.Hit.p) <= 10.4 then
  511. local humanoid = Mouse.Target.Parent:FindFirstChild("Humanoid")
  512. if humanoid then
  513. humanoid.Health = humanoid.Health - 10
  514. local parts = Mouse.Target.Parent:GetChildren()
  515. for _,p in pairs(parts) do
  516. if p.ClassName == "Part" then
  517. 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))
  518. end
  519. end
  520. return
  521. end
  522. local x = Mouse.Target.CFrame.p.X
  523. local y = Mouse.Target.CFrame.p.Y
  524. local z = Mouse.Target.CFrame.p.Z
  525. if Mouse.TargetSurface.Name == "Right" then x = x + 2.6 end
  526. if Mouse.TargetSurface.Name == "Left" then x = x - 2.6 end
  527. if Mouse.TargetSurface.Name == "Top" then y = y + 2.6 end
  528. if Mouse.TargetSurface.Name == "Bottom" then y = y - 2.6 end
  529. if Mouse.TargetSurface.Name == "Back" then z = z + 2.6 end
  530. if Mouse.TargetSurface.Name == "Front" then z = z - 2.6 end
  531. if Mouse.Target.Size.X > 2.6 or Mouse.Target.Size.Y > 2.6 or Mouse.Target.Size.Z > 2.6 then
  532. x = Mouse.Hit.p.X
  533. y = Mouse.Hit.p.Y
  534. z = Mouse.Hit.p.Z
  535. end
  536. -- local x = round(math.abs(mouseX)/2.6)*2.6
  537. -- local y = round(math.abs(mouseY)/2.6)*2.6
  538. -- local z = round(math.abs(mouseZ)/2.6)*2.6
  539. -- if Mouse.Hit.p.X < 0 then x = x * -1 end
  540. -- if Mouse.Hit.p.Y < 0 then y = y * -1 end
  541. -- if Mouse.Hit.p.Z < 0 then z = z * -1 end
  542. if selectedBlock == 0 then
  543. local blk = placeBlock(toolBar.Dirt, CFrame.new(x, y, z))
  544. for _,f in pairs(facesToResize) do
  545. blk:WaitForChild(f).StudsPerTileU = 2.6
  546. blk:WaitForChild(f).StudsPerTileV = 2.6
  547. end
  548. elseif selectedBlock == 1 then
  549. local blk = placeBlock(toolBar.Grass, CFrame.new(x, y, z))
  550. for _,f in pairs(facesToResize) do
  551. blk:WaitForChild(f).StudsPerTileU = 2.6
  552. blk:WaitForChild(f).StudsPerTileV = 2.6
  553. end
  554. elseif selectedBlock == 2 then
  555. local blk = placeBlock(toolBar.Stone, CFrame.new(x, y, z))
  556. for _,f in pairs(facesToResize) do
  557. blk:WaitForChild(f).StudsPerTileU = 2.6
  558. blk:WaitForChild(f).StudsPerTileV = 2.6
  559. end
  560. elseif selectedBlock == 3 then
  561. local blk = placeBlock(toolBar.Diamond_Ore, CFrame.new(x, y, z))
  562. for _,f in pairs(facesToResize) do
  563. blk:WaitForChild(f).StudsPerTileU = 2.6
  564. blk:WaitForChild(f).StudsPerTileV = 2.6
  565. end
  566. elseif selectedBlock == 4 then
  567. local blk = placeBlock(toolBar.Diamond_Block, CFrame.new(x, y, z))
  568. for _,f in pairs(facesToResize) do
  569. blk:WaitForChild(f).StudsPerTileU = 2.6
  570. blk:WaitForChild(f).StudsPerTileV = 2.6
  571. end
  572. elseif selectedBlock == 5 then
  573. local blk = placeBlock(toolBar.Wood_Planks, CFrame.new(x, y, z))
  574. for _,f in pairs(facesToResize) do
  575. blk:WaitForChild(f).StudsPerTileU = 2.6
  576. blk:WaitForChild(f).StudsPerTileV = 2.6
  577. end
  578. elseif selectedBlock == 6 then
  579. local blk = placeBlock(toolBar.Oak_Log, CFrame.new(x, y, z))
  580. for _,f in pairs(facesToResize) do
  581. blk:WaitForChild(f).StudsPerTileU = 2.6
  582. blk:WaitForChild(f).StudsPerTileV = 2.6
  583. end
  584. elseif selectedBlock == 7 or selectedBlock == 8 then
  585. if Mouse.Target.Size.X <= 10 and Mouse.Target.Size.Y <= 10 and Mouse.Target.Size.Z <= 10 then
  586. Mouse.Target.Parent = nil
  587. end
  588. end
  589. end
  590. end
  591. end)
  592.  
  593. local hasItemOnHand = 0
  594. local hi = 0
  595. -- selection thingy
  596. local selectLabel = Instance.new("TextLabel", gui)
  597. selectLabel.Size = UDim2.new(0, 32, 0, 32)
  598. selectLabel.Position = UDim2.new(0.5, -160 + (selectedBlock*40), 1, -105)
  599. selectLabel.BackgroundTransparency = 0.5
  600. selectLabel.BackgroundColor3 = Color3.new(1, 1, 1)
  601. selectLabel.BorderSizePixel = 0
  602. selectLabel.Text = ""
  603. selectLabel.ZIndex = 3
  604. --
  605. Mouse.KeyDown:connect(function(key)
  606. if key == "q" then
  607. sneaking = 1
  608. humanoid.WalkSpeed = humanoid.WalkSpeed / 2
  609. rootJoint.C1 = CFrame.new(0, 0.325, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  610. lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45), 0, 0)
  611. rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  612. print("Sneaking...")
  613. end
  614. if key == "8" then
  615. selectedBlock = 7
  616. itemOnHand = nil
  617. for _,d in pairs(handItem:GetChildren()) do
  618. d:Destroy()
  619. end
  620. if hasItemOnHand == 1 then hi = 1 end
  621. end
  622. if key == "9" then
  623. selectedBlock = 8
  624. itemOnHand = nil
  625. for _,d in pairs(handItem:GetChildren()) do
  626. d:Destroy()
  627. end
  628. if hasItemOnHand == 1 then hi = 1 end
  629. end
  630. if key == "1" then
  631. selectedBlock = 0
  632. itemOnHand = toolBar.Dirt
  633. for _,d in pairs(handItem:GetChildren()) do
  634. d:Destroy()
  635. end
  636. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  637. itemOnHand.topTex, itemOnHand.bottomTex,
  638. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  639. for _,f in pairs(facesToResize) do
  640. handItem:WaitForChild(f).StudsPerTileU = 0.52
  641. handItem:WaitForChild(f).StudsPerTileV = 0.52
  642. end
  643. end
  644. if key == "2" then
  645. selectedBlock = 1
  646. itemOnHand = toolBar.Grass
  647. for _,d in pairs(handItem:GetChildren()) do
  648. d:Destroy()
  649. end
  650. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  651. itemOnHand.topTex, itemOnHand.bottomTex,
  652. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  653. for _,f in pairs(facesToResize) do
  654. handItem:WaitForChild(f).StudsPerTileU = 0.52
  655. handItem:WaitForChild(f).StudsPerTileV = 0.52
  656. end
  657. end
  658. if key == "3" then
  659. selectedBlock = 2
  660. itemOnHand = toolBar.Stone
  661. for _,d in pairs(handItem:GetChildren()) do
  662. d:Destroy()
  663. end
  664. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  665. itemOnHand.topTex, itemOnHand.bottomTex,
  666. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  667. for _,f in pairs(facesToResize) do
  668. handItem:WaitForChild(f).StudsPerTileU = 0.52
  669. handItem:WaitForChild(f).StudsPerTileV = 0.52
  670. end
  671. end
  672. if key == "4" then
  673. selectedBlock = 3
  674. itemOnHand = toolBar.Diamond_Ore
  675. for _,d in pairs(handItem:GetChildren()) do
  676. d:Destroy()
  677. end
  678. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  679. itemOnHand.topTex, itemOnHand.bottomTex,
  680. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  681. for _,f in pairs(facesToResize) do
  682. handItem:WaitForChild(f).StudsPerTileU = 0.52
  683. handItem:WaitForChild(f).StudsPerTileV = 0.52
  684. end
  685. end
  686. if key == "5" then
  687. selectedBlock = 4
  688. itemOnHand = toolBar.Diamond_Block
  689. for _,d in pairs(handItem:GetChildren()) do
  690. d:Destroy()
  691. end
  692. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  693. itemOnHand.topTex, itemOnHand.bottomTex,
  694. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  695. for _,f in pairs(facesToResize) do
  696. handItem:WaitForChild(f).StudsPerTileU = 0.52
  697. handItem:WaitForChild(f).StudsPerTileV = 0.52
  698. end
  699. end
  700. if key == "6" then
  701. selectedBlock = 5
  702. itemOnHand = toolBar.Wood_Planks
  703. for _,d in pairs(handItem:GetChildren()) do
  704. d:Destroy()
  705. end
  706. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  707. itemOnHand.topTex, itemOnHand.bottomTex,
  708. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  709. for _,f in pairs(facesToResize) do
  710. handItem:WaitForChild(f).StudsPerTileU = 0.52
  711. handItem:WaitForChild(f).StudsPerTileV = 0.52
  712. end
  713. end
  714. if key == "7" then
  715. selectedBlock = 6
  716. itemOnHand = toolBar.Oak_Log
  717. for _,d in pairs(handItem:GetChildren()) do
  718. d:Destroy()
  719. end
  720. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  721. itemOnHand.topTex, itemOnHand.bottomTex,
  722. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  723. for _,f in pairs(facesToResize) do
  724. handItem:WaitForChild(f).StudsPerTileU = 0.52
  725. handItem:WaitForChild(f).StudsPerTileV = 0.52
  726. end
  727. end
  728. if (key == "0" or key == "1" or key == "2"
  729. or key == "3" or key == "4" or key == "5"
  730. or key == "6" or key == "7") and hasItemOnHand == 0 then hi = 1 end
  731. selectLabel.Position = UDim2.new(0.5, -160 + ((selectedBlock)*40), 1, -105)
  732. end)
  733.  
  734. Mouse.KeyUp:connect(function(key)
  735. if key == "q" then
  736. sneaking = 0
  737. humanoid.WalkSpeed = humanoid.WalkSpeed * 2
  738. rootJoint.C1 = CFrame.new(0, 0.05, 0) * CFrame.Angles(0, 0, 0)
  739. lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(0, 0, 0)
  740. rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(0, 0, 0)
  741. print("Stopped sneaking...")
  742. end
  743. end)
  744.  
  745. while RS:wait() do
  746. if itemOnHand ~= nil then
  747. hasItemOnHand = 1
  748. handItem.Transparency = 0
  749. else
  750. hasItemOnHand = 0
  751. handItem.Transparency = 1
  752. end
  753. if humanoid.Health < oldHP then
  754. damageTime = 60
  755. sound:Play()
  756. end
  757. oldHP = humanoid.Health
  758. if damageTime > 0 and humanoid.Health > 0 then
  759. for _,p in pairs(char:GetChildren()) do
  760. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  761. if p.Name == "DamagePart" then
  762. p.Transparency = 0.5
  763. end
  764. end
  765. end
  766. damageTime = damageTime - 2
  767. if damageTime <= 0 then
  768. for _,p in pairs(char:GetChildren()) do
  769. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  770. if p.Name == "DamagePart" then
  771. p.Transparency = 1
  772. end
  773. end
  774. end
  775. end
  776. end
  777. camPart.CFrame = camera.CFrame
  778. neck.C1 = CFrame.new(0, 0.975, 0) * CFrame.fromEulerAnglesXYZ(math.rad(sneaking*45), math.rad(camPart.Orientation.Y - torso.Orientation.Y), 0)
  779. neck.C0 = CFrame.new(0, -0.65, 0) * CFrame.Angles(-math.rad(camPart.Orientation.X - torso.Orientation.X - (sneaking*45)), 0, 0)
  780.  
  781. if getMagnitudeXZ(torso.Velocity) > 1 then
  782. if walkAnim >= 1 then
  783. increaseWalkAnim = -1
  784. elseif walkAnim <= -1 then
  785. increaseWalkAnim = 1
  786. end
  787. walkAnim = walkAnim + (increaseWalkAnim/(10+(sneaking*20)))
  788. else
  789. walkAnim = 0
  790. end
  791.  
  792. --lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45), 0, 0)
  793. --rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  794. 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)
  795. 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)
  796. --
  797. --rootJoint.C0 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
  798. --print(math.abs(head.Orientation.Y) - math.abs(humRootPart.Orientation.Y))
  799. --if (head.Orientation.Y * 2) - (head.Orientation.Y + torso.Orientation.Y) > 45 then
  800. --humRootPart.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(-45 + head.Orientation.Y), 0)
  801. --print("-45")
  802. --end
  803. --if (head.Orientation.Y * 2) - (head.Orientation.Y + torso.Orientation.Y) < -45 then
  804. --humRootPart.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(45 + head.Orientation.Y), 0)
  805. --print("45")
  806. --end
  807.  
  808. --move these arms
  809. rootJoint.C1 = rootJoint.C1:lerp(CFrame.new(0, 0.325, 0) * CFrame.Angles(math.rad(sneaking*45), math.rad(punchRotY), 0), 0.2)
  810.  
  811. 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)
  812. 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))
  813. if punching == 1 and punchEnded == 1 then
  814. punching = 0
  815. print("steve uses punch!!")
  816. local coPunch = coroutine.wrap(function()
  817. punchEnded = 0
  818. punchSpeed = 1
  819. punchRotX = -60
  820. punchRotY = -8
  821. punchRotZ = -35
  822. wait(0.075)
  823. punchSpeed = 1
  824. punchRotX = -75
  825. punchRotY = 8
  826. punchRotZ = 40
  827. wait(0.075)
  828. punchSpeed = 1
  829. punchRotX = -20
  830. punchRotZ = 40
  831. wait(0.075)
  832. punchSpeed = 3.5
  833. punchRotX = 0
  834. punchRotY = 0
  835. punchRotZ = 0
  836. punchEnded = 1
  837. wait(0.06)
  838. punchSpeed = 0
  839. end)
  840. coPunch()
  841. end
  842. if ticks > 20 then
  843. ticks = 0
  844. if times == 0 then
  845. times = times + 1
  846. idleAnimRotX = -1
  847. idleAnimRotZ = 0
  848. elseif times == 1 then
  849. times = times + 1
  850. idleAnimRotX = -0.75
  851. idleAnimRotZ = -0.75
  852. elseif times == 2 then
  853. times = times + 1
  854. idleAnimRotX = 0
  855. idleAnimRotZ = -1
  856. elseif times == 3 then
  857. times = times + 1
  858. idleAnimRotX = 0.75
  859. idleAnimRotZ = -0.75
  860. --idleAnimRotX = 0.75
  861. --idleAnimRotZ = -0
  862. elseif times == 4 then
  863. times = times + 1
  864. idleAnimRotX = 1
  865. idleAnimRotZ = 0
  866. --idleAnimRotX = 1
  867. --idleAnimRotZ = 0
  868. elseif times == 5 then
  869. times = times + 1
  870. idleAnimRotX = 0.75
  871. idleAnimRotZ = 0.75
  872. elseif times == 6 then
  873. times = times + 1
  874. idleAnimRotX = 0
  875. idleAnimRotZ = 1
  876. elseif times == 7 then
  877. times = 0
  878. idleAnimRotX = -0.75
  879. idleAnimRotZ = 0.75
  880. end
  881. end
  882. if hi == 1 then hi = 0 end
  883. ticks = ticks + 1
  884. end
  885. end
  886. end
Add Comment
Please, Sign In to add comment