Humanoid.Running not working

I’m trying to make it so that whenever any player walks it will update the distance the player is from a certain part, but the humanoid.Running event is not firing. This script is initially disabled and re-enabled somewhere else in the game. It prints the character’s name and then ends with no errors.

Players = game:GetService("Players")
for i,v in pairs(Players:GetChildren()) do ---- all the players who haven't been added yet, connect them to the list
    char = game.Workspace[v.Name] 
    print("This is where the running should occur")
    print(char.Name)
    --    for i,v in pairs (char:GetChildren()) do print(v) end
    local humanoidC = char:FindFirstChild("Humanoid")
    humanoidC.Running:Connect(function(speed)
        print("Running")
        print(char.Name.."2")
        if speed > 0 then
            print(char.Name.."3")
            print(speed)
            onWalkUpdatePlayerDistance(char)
        end    
    end)
end
1 Like
Players = game:GetService("Players")

for _, plr in ipairs(Players:GetPlayers()) do ---- all the players who haven't been added yet, connect them to the list
    char = plr.Character or plr.CharacterAdded:Wait()
    print("This is where the running should occur")
    print(char.Name)
    --    for _,CharPart in ipairs (char:GetChildren()) do print(v) end
    local humanoidC = char:WaitForChild("Humanoid")
    humanoidC.Running:Connect(function(speed)
        print("Running")
        print(char.Name.."2")
        if speed > 0 then
            print(char.Name.."3")
            print(speed)
            onWalkUpdatePlayerDistance(char)
        end    
    end)
end

Try it, if something unexpected happens don’t forget to tell us.

1 Like

I tested your code, and it says: 13:12:39.749 - bacionhairmanfur2 is not a valid member of Workspace

So use CharacterAdded, and try that, as @PhoenixRessusection Said.

And, onWalkUpdatePlayerDistance is not a function.

1 Like

To be honest, it may be, since we are not sure if that was the full script.

1 Like

Yes, this wasn’t the full script. What @PhoenixRessusection suggested is working, thanks.

1 Like