[SOLVED BY MYSELF]
I want this script to detect when a player is moving, and give speed if they are. It was working at one point, and still is, just not all the time.
What I mean by this, is if my speed suddenly changes, it'll detect me moving, but if I'm moving at a relatively constant speed, it doesn't.
I've tried a lot of different things, and nothing is working. Here is the code, any help is appreciated.
game.Players.PlayerAdded:Connect(function(player) player:WaitForChild("leaderstats"):WaitForChild("Cardio") local Debounce = false local Speed = player.Speed local TotalSpeed = player.TotalSpeed local Cardio = player.leaderstats.Cardio local TotalCardio = player.TotalCardio local SpeedMulti = player.SpeedMulti local Char = game.Workspace:WaitForChild(player.Name) while true do Char.Humanoid.Running:Connect(function(speed) if Debounce == false and speed > 0 then print(speed) Debounce = true Speed.Value = Speed.Value + 1 * SpeedMulti.Value TotalSpeed.Value = TotalSpeed.Value + 1 * SpeedMulti.Value Cardio.Value = Cardio.Value + 1 * SpeedMulti.Value TotalCardio.Value = TotalCardio.Value + 1 * SpeedMulti.Value end end) wait(1) Debounce = false end end)
Edit: The print(speed) also doesn't print.
And once again, I ended up solving it myself... Maybe I should just never ask a question. But anyways, here's what I did to make it work:
game.Players.PlayerAdded:Connect(function(player) player:WaitForChild("leaderstats"):WaitForChild("Cardio") local Speed = player.Speed local TotalSpeed = player.TotalSpeed local Cardio = player.leaderstats.Cardio local TotalCardio = player.TotalCardio local SpeedMulti = player.SpeedMulti local Char = game.Workspace:WaitForChild(player.Name) local runSpeed Char.Humanoid.Running:Connect(function(speed) runSpeed = speed end) while true do wait(1) if runSpeed == nil then elseif runSpeed > 0 then Speed.Value = Speed.Value + 1 * SpeedMulti.Value TotalSpeed.Value = TotalSpeed.Value + 1 * SpeedMulti.Value Cardio.Value = Cardio.Value + 1 * SpeedMulti.Value TotalCardio.Value = TotalCardio.Value + 1 * SpeedMulti.Value end end end)