Ad
Log in to vote
0

Speed and HighestSpeed not changing (leaderstats)?

Asked by 19 days ago

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!

0
On line 18, you just typed; Speed.Value = Character.Humanoid.Walkspeed. You did not define the player in a variable nor the character. On the very top of you script, try making a variable that defines the player, and a variable that defines the character. TheKittyKingOfficial 2 — 19d
0
I dont know if this is the problem, but try it. TheKittyKingOfficial 2 — 19d
0
that isn't the problem. He might not be using the output so really they need to put character:WaitForChild('Humanoid') since it is playeradded and not characteradded greatneil80 2641 — 18d
0
That didn't work greatniel80 Puppy_lovertheawsome 32 — 18d
0
In that case you are using a localscript, use a regular script and parent it to workspace instead. The PlayerAdded wasn't working to begin with since it is a localscript, I probably should've mentioned this earlier greatneil80 2641 — 17d

1 answer

Log in to vote
0
Answered by
NykoVania 198 Moderation Voter
19 days ago

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
)

0
Ok I'll try it! Puppy_lovertheawsome 32 — 19d
0
Sadly It didn't work :( Puppy_lovertheawsome 32 — 19d
Ad

Answer this question