Er1x_Official

Local Script, Barrage Tutorial

Sep 12th, 2021
3,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. -- local script
  2. local m = game:GetService("Players").LocalPlayer:GetMouse() -- get the player, and get the players mouse (YOU)
  3. local activ = false -- if the tool is activated
  4.  
  5. script.Parent.Activated:Connect(function() -- activation trigger
  6.     activ = true -- activated = true
  7.     while task.wait() do -- while activated
  8.         if activ then
  9.             local direction = (m.Hit.p - script.Parent.Parent.HumanoidRootPart.Position) * Vector3.new(1, 0, 1)
  10.             script.Parent.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.HumanoidRootPart.Position, script.Parent.Parent.HumanoidRootPart.Position + direction) -- root will follow the mouse
  11.             script.Parent.RemoteEvent:FireServer(m.Hit) -- fire the remote
  12.         else break
  13.         end
  14.     end
  15. end)
  16.  
  17. script.Parent.Deactivated:Connect(function() -- deactivate and stop the loop
  18.     activ = false
  19. end)
Advertisement
Add Comment
Please, Sign In to add comment