Advertisement
samuelrichter66

Untitled

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