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

How does the changed event work?

character:WaitForChild("Humanoid").MoveDirection.Changed:connect(record)

I have this event caller that calls every time the movedirection property of humanoid changes. So far the event does not respond. What can be done to fix this?

Edit:

character.Humanoid.Running:connect(function(speed)

print("running")

if speed > 0 then

  print("Character has moved")
  local locval = Instance.new("Vector3Value")
  locval.Value = torso.Position
  locval.Name = Seconds
  locval.Parent = movementdata
  movementdata = locval	
  local brickplacement = Instance.new("Part")
  brickplacement.CanCollide = false
  brickplacement.Positon = torso.Position
  brickplacement.Parent = game.Workspace
  Seconds = 0

end

end)

I changed it to this, but no sign of anything happening. No printing is occuring in the output

1 answer

In this case you're trying to use a property as an event MoveDirection is a property not an event, it is a read only Vector3 described below in the wiki, which means it can only be read, if you look at the bottom of the wiki back below it shows a list of events that the humanoid does use.

http://wiki.roblox.com/index.php?title=API:Class/Humanoid

I believe what you're looking for is the running event which also returns the players speed as well as fires the function like how you want it to work. Keep in mind running does also triggers the event if they are at 0 walkspeed which means you need to put in a if statement if you don't want the function or code to fire while the player is idle, which is explained in the running event wiki page below

http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Running

1 comment

0

I've changed the event to running. Nothing is showing up. I updated the script and pasted in the new version

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