Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- local script
- local m = game:GetService("Players").LocalPlayer:GetMouse() -- get the player, and get the players mouse (YOU)
- local activ = false -- if the tool is activated
- script.Parent.Activated:Connect(function() -- activation trigger
- activ = true -- activated = true
- while task.wait() do -- while activated
- if activ then
- local direction = (m.Hit.p - script.Parent.Parent.HumanoidRootPart.Position) * Vector3.new(1, 0, 1)
- script.Parent.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.HumanoidRootPart.Position, script.Parent.Parent.HumanoidRootPart.Position + direction) -- root will follow the mouse
- script.Parent.RemoteEvent:FireServer(m.Hit) -- fire the remote
- else break
- end
- end
- end)
- script.Parent.Deactivated:Connect(function() -- deactivate and stop the loop
- activ = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment