I am trying to make my script repeat so I am using While true do however whenever I use it it does Game script timeout. I think I need wait somewhere but I've put it everywhere I can think of. Here's the code:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid") while true do if player.leaderstats.speed.Value <= 16 then humanoid.WalkSpeed = 16 else humanoid.WalkSpeed = 0.1 * player.leaderstats.speed.Value wait(1) end end end) end)
Your wait(1) function is inside the else statement, meaning that if the original condition is met(player.leaderstats.speed.Value <= 16) then the program won't wait.
fix:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid") while true do if player.leaderstats.speed.Value <= 16 then humanoid.WalkSpeed = 16 wait(1) else humanoid.WalkSpeed = 0.1 * player.leaderstats.speed.Value wait(1) end end end) end)