of     1   

1Sanic1
#221331798Friday, July 14, 2017 9:05 PM GMT

I am trying to write a script. It is walk speed acceleration. However I want the walk speed to reset when the player stops. I am trying to check if their speed is 0 and if it is it resets the walk speed. When I use it I get the error "attempt to compare number with userdata" any ideas on how to fix this? My code. Local script local speed = script.Parent.Humanoid while true do if speed.WalkSpeed >= 30 and speed.WalkSpeed <= 50 then wait(1) speed.WalkSpeed = speed.WalkSpeed + 2 local runspeed = speed.Running if runspeed > 0 then print("Running") else speed.WalkSpeed = 30 end end wait() end
LeafDoode
#221332522Friday, July 14, 2017 9:15 PM GMT

so you mean when their walk speed is equal to 0 you want it to be 30? or do you mean when they stop walking you want it to reset to 30 can you re-explain
1Sanic1
#221332974Friday, July 14, 2017 9:21 PM GMT

When they stop walking
Mescalyne
#221333114Friday, July 14, 2017 9:23 PM GMT

Humanoid.Running is a signal, not a number. No wonder you get the error.
1Sanic1
#221333903Friday, July 14, 2017 9:35 PM GMT

Dumb question... How can I check it
Mescalyne
#221334513Friday, July 14, 2017 9:42 PM GMT

local hum = script.Parent.Humanoid hum.Running:connect(function(spd) if spd > 0 then -- started running while hum.MoveDirection.magnitude > 0 do wait() hum.WalkSpeed = math.clamp(hum.WalkSpeed + 0.5, 0, 45) end else -- stopped running hum.WalkSpeed = 16 end end) i'd personally recommend just using the running event because it also fires when running stops so you can reset speed also I clamped the value at a max of 45 but you can use whatever method to change the player's speed

    of     1