Advertisement
samuelrichter66

minekampf

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