Advertisement
Guest User

Untitled

a guest
Jan 11th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local tool = script.Parent
  2. local camera = game:GetService("Workspace").CurrentCamera
  3. local runService = game:GetService("RunService")
  4. local plr = game:GetService("Players").LocalPlayer
  5. local char = plr.Character or plr.CharacterAdded:Wait()
  6. local toolActivated = false
  7. local mouse = plr:GetMouse()
  8. local UserInputService = game:GetService("UserInputService")
  9. local BodyGyro = Instance.new("BodyGyro")
  10. local HumanoidRootPart
  11. local humanoid = char:WaitForChild("Humanoid")
  12.  
  13. BodyGyro.MaxTorque = Vector3.new(100000000, 100000000, 100000000)
  14. BodyGyro.D = 200
  15. BodyGyro.P = 9000
  16.  
  17.  
  18. tool.Activated:Connect(function()
  19.     toolActivated = true
  20.     BodyGyro.Parent = HumanoidRootPart
  21. end)
  22.  
  23.  
  24. tool.Deactivated:Connect(function()
  25.     toolActivated = false
  26.     BodyGyro.Parent = nil
  27. end)
  28.  
  29. runService.RenderStepped:Connect(function()
  30.     if humanoid.Health > 0 and toolActivated then
  31.         HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
  32.         local HRPpos = HumanoidRootPart.Position
  33.         BodyGyro.CFrame = CFrame.new(HRPpos, Vector3.new(mouse.Hit.Position.x, HRPpos.y, mouse.Hit.Position.z)) -- Make the HumanoidRootPart face the direction of the mouse cursor through a BodyGyro.
  34.     end
  35. end)
  36.  
  37. humanoid.Died:Connect(function()
  38.     BodyGyro:Destroy()
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement