Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you make a movement detector?

Asked by
Fiddlepat -12
5 years ago

How do you make a detector for movement? I've been trying various methods, anyone have some pointers? Just a basic movement detector.

2 answers

Log in to vote
0
Answered by
Imperialy 149
5 years ago
humanoid.Running:Connect(function(speed)
    if speed >0 then
        print('running')
    end
end)
0
this will fire whenever the speed changes, so if the walkspeed is altered it will cause the print to run Gey4Jesus69 2705 — 5y
0
you could also use magnitude Imperialy 149 — 5y
0
Doesn't work, how does it even detect the humanoid? I'm using a hit detect but it's not working. Fiddlepat -12 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Assuming you mean movement for players, you can use the StateChanged event of Humanoids.This works in either a local or a server script, but I'll show an example on the server-side:

game:GetService("Players").PlayerAdded:Connect(function(plr)
   local char = plr.Character or plr.CharacterAdded:Wait()
   local humanoid = char:WaitForChild("Humanoid")
   humanoid.StateChanged:Connect(function(old,new)
      if new == Enum.HumanoidStateType.Running then
         print("Movement begun")
      end
   end
end)
1
isn't that the same script i basically did lol Imperialy 149 — 5y
0
shhh no one has to know Gey4Jesus69 2705 — 5y

Answer this question