Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tool = script.Parent
- local camera = game:GetService("Workspace").CurrentCamera
- local runService = game:GetService("RunService")
- local plr = game:GetService("Players").LocalPlayer
- local char = plr.Character or plr.CharacterAdded:Wait()
- local toolActivated = false
- local mouse = plr:GetMouse()
- local UserInputService = game:GetService("UserInputService")
- local BodyGyro = Instance.new("BodyGyro")
- local HumanoidRootPart
- local humanoid = char:WaitForChild("Humanoid")
- BodyGyro.MaxTorque = Vector3.new(100000000, 100000000, 100000000)
- BodyGyro.D = 200
- BodyGyro.P = 9000
- tool.Activated:Connect(function()
- toolActivated = true
- BodyGyro.Parent = HumanoidRootPart
- end)
- tool.Deactivated:Connect(function()
- toolActivated = false
- BodyGyro.Parent = nil
- end)
- runService.RenderStepped:Connect(function()
- if humanoid.Health > 0 and toolActivated then
- HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
- local HRPpos = HumanoidRootPart.Position
- 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.
- end
- end)
- humanoid.Died:Connect(function()
- BodyGyro:Destroy()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement