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 TweenService = game:GetService("TweenService")
- local TweenTime = 0.1
- local lookTween
- local canPlayTween = false
- tool.Activated:Connect(function()
- toolActivated = true
- canPlayTween = true
- end)
- tool.Deactivated:Connect(function()
- toolActivated = false
- end)
- runService.Heartbeat:Connect(function()
- if toolActivated then
- local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
- local HRPpos = HumanoidRootPart.Position
- local goal = {}
- goal.CFrame = CFrame.new(HRPpos, Vector3.new(mouse.Hit.Position.x, HRPpos.y, mouse.Hit.Position.z))
- local tweenInfo = TweenInfo.new(TweenTime)
- lookTween = TweenService:Create(HumanoidRootPart, tweenInfo, goal)
- if canPlayTween then
- lookTween:Play()
- canPlayTween = false
- else
- HumanoidRootPart.CFrame = CFrame.new(HRPpos, Vector3.new(mouse.Hit.Position.x, HRPpos.y, mouse.Hit.Position.z))
- lookTween:Cancel()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment