function PlayerClient:IsState(State)
Humanoid.StateChanged:Connect(function(_OldState,NewState)
if NewState == State then
return true
end
end)
end
function PlayerClient:IsRunning()
if PlayerClient:IsState(Enum.HumanoidStateType.Running) then
return true
end
end
#humanoid.statechanged not working with modulescript (solved)
1 messages · Page 1 of 1 (latest)
while task.wait() do
if PlayerClient:IsRunning() then
print("YABBADABBA")
end
doesnt print anything
function PlayerClient:isrunning()
if Humanoid.MoveDirection.Magnitude > 0 then
return true
end
end
this works fine though somehow
id rather use humanoid states though
this is in a localscript
the other code snippets are in modules
So you're returning from the connection's scope, not the actual accessor scope. All the accessor is doing is generating new connections to StateChanged.
What you should do instead is have
currentHumanoidState = Enum.HumanoidStateType.None
Humanoid.StateChanged:Connect(function(old,new)
currentHumanoidState = new
end)
and then in the accessor, you can compare the State parameter to currentHumanoidState, and this should yield your intended result
full implementation
currentHumanoidState = Enum.HumanoidStateType.None
Humanoid.StateChanged:Connect(function(old,new)
currentHumanoidState = new
end)
function PlayerClient:IsState( State )
return State == currentHumanoidState
end
function PlayerClient:IsRunning()
if PlayerClient:IsState(Enum.HumanoidStateType.Running) then
return true
end
end
or even better
function PlayerClient:IsRunning()
return PlayerClient:IsState(Enum.HumanoidStateType.Running)
end
I'll try this out later after I come back
this works thanks
too bad the default humanoid states are broken
.running fires even when standing still
ill just do that using humanoid.movedirection then
You can use the speed parameter of the event to determine if the Running state has become standing https://create.roblox.com/docs/reference/engine/classes/Humanoid#Running
but yea movedirection works fine