Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can you make a movement detector?

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

humanoid.Running:Connect(function(speed)
	if speed >0 then
		print('running')
	end
end)

3 comments

0

this will fire whenever the speed changes, so if the walkspeed is altered it will cause the print to run

0

you could also use magnitude

0

Doesn't work, how does it even detect the humanoid? I'm using a hit detect but it's not working.

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)

2 comments

1

isn't that the same script i basically did lol

0

shhh no one has to know

This discussion is preserved as it was. New answers, comments, and votes are closed.