Advertisement
Nova355killer

Gold Axe lumber

Apr 13th, 2019
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. Detect = coroutine.wrap(function()
  2. Player = game.Players.LocalPlayer
  3. mouse = Player:GetMouse()
  4. mouse.Button1Down:connect(function()
  5. MouseDown = true
  6. end)
  7. mouse.Button1Up:connect(function()
  8. MouseDown = false
  9. end)
  10. end)
  11. Detect()
  12. Player = game.Players.LocalPlayer
  13. mouse = Player:GetMouse()
  14. game:GetService('RunService').RenderStepped:connect(function()
  15. if Player.Character:FindFirstChild("Tool") then
  16. if MouseDown == true then
  17. if mouse.Target.Name == "WoodSection" then
  18. targetWood = mouse.Target
  19. Tool=Player.Character.Tool
  20. ---FaceVector
  21. Height = targetWood.CFrame:pointToObjectSpace(mouse.Hit.p).Y + targetWood.Size.Y/2
  22. local ray = Ray.new(Player.Character.Head.Position, ((targetWood.CFrame * CFrame.new(0, Height - targetWood.Size.Y/2, 0)).p - Player.Character.Head.Position).unit * 200)
  23. part,_,p = workspace:FindPartOnRay(ray, Player.Character)
  24. function fixVector(V)
  25. return Vector3.new(math.floor(V.X + 0.5), math.floor(V.Y + 0.5), math.floor(V.Z + 0.5))
  26. end
  27. local faceVector = fixVector(targetWood.CFrame:vectorToObjectSpace(p))
  28. if faceVector.Y ~= 0 then
  29. return
  30. end
  31. local lookAtCFrame = CFrame.new(Player.Character.Head.Position, mouse.Hit.p)
  32. local relativeCFrame = lookAtCFrame:toObjectSpace(targetWood.CFrame * CFrame.Angles(math.pi/2, 0, 0))
  33. local relativeLookVector = relativeCFrame.lookVector
  34. local m = relativeLookVector.Y >= 0 and 1 or -1
  35. if faceVector.X == 1 then
  36. faceVector = Vector3.new(0, 0, -1) * m
  37. elseif faceVector.X == -1 then
  38. faceVector = Vector3.new(0, 0, 1) * m
  39. elseif faceVector.Z == 1 then
  40. faceVector = Vector3.new(1, 0, 0) * m
  41. elseif faceVector.Z == -1 then
  42. faceVector = Vector3.new(-1, 0, 0) * m
  43. end
  44. local cutEvent = targetWood.Parent.CutEvent
  45. game.ReplicatedStorage.Interaction.RemoteProxy:FireServer(cutEvent, {sectionId = targetWood.ID.Value, faceVector = faceVector, height = Height, hitPoints = 0.2, cooldown = 0, cuttingClass = "Axe", tool = Player.Character.Tool})
  46. end
  47. end
  48. end
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement