I have been trying to make the characters speed and highest ever speed show on leaderstats but I cannot get it to work:
game.Players.PlayerAdded:Connect(function(player) local character = player.Character local leaderstats = Instance.new("BoolValue",player) leaderstats.Name = "leaderstats" local Speed = Instance.new("IntValue", leaderstats) Speed.Name = "Speed" local HighestSpeed = Instance.new("IntValue", leaderstats) HighestSpeed.Name = "HighestSpeed" Speed.Value = 0 HighestSpeed.Value = 0 while true do--this is where it could stop working task.wait()--or maybe here Speed.Value = character.Humanoid.WalkSpeed--probably here if Speed.Value > HighestSpeed.Value then HighestSpeed.Value = Speed.Value end end end)
The while true do loop does not run
If anyone has a solution I would love the help!
Try this?
Script:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local leaderstats = Instance.new("BoolValue", player) leaderstats.Name = "leaderstats" local Speed = Instance.new("IntValue", leaderstats) Speed.Name = "Speed" local HighestSpeed = Instance.new("IntValue", leaderstats) HighestSpeed.Name = "HighestSpeed" Speed.Value = 0 HighestSpeed.Value = 0 while wait() do Speed.Value = character.Humanoid.WalkSpeed if Speed.Value > HighestSpeed.Value then HighestSpeed.Value = Speed.Value end end end ) end )