Im making a game where i need the player to be able to train their movement speed by walking, but i don’t know how could i detect if the player is moving. I need it to add +1 movement speed every second while the player is moving. Maybe like check the players velocity?
You can also use the humanoid.Running event to change a variable as so.
local isRunning = false
Humanoid.Running:Connect(function(speed)
if speed <= 0 then isRunning = false return end
isRunning = true
end)
while task.wait(1) do
if isRunning then
-- code
end
end
However, you would need to re-establish this event if the players character were to respawn, so you can put the event under a CharacterAdded event aswell.
i think its because where he put the variable, it only gets assigned once. he would have had to put the condition inside the loop so it can be checked each time