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
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.