Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Big question ! , Why does the StringValue show nothing ?!

Asked by 3 years ago
game.Players.PlayerAdded:Connect(function(players)
    local folder = Instance.new("Folder",players)
    folder.Name = "leaderstats"
    local Points = Instance.new("IntValue",folder)
    Points.Value = 0 
    Points.Name = "Points"
    local Rank = Instance.new("StringValue",folder)
    Rank.Name = "Amateur"
    while true do 
        wait(5)
        Points.Value = Points.Value + 1
    end
    if Points.Value > 9 then
        Rank.Value = "Better"
    end 
end)

Im currently trying to make a a rank system EX : 10 points you can get the "Better" rank , but instead of working . When the points hit 10 , nothing happens , the rank is still at Amateur . I put this script in ServerScriptStorage , the outputs shows no errors , Any help would be greatful !

2 answers

Log in to vote
1
Answered by
TickoGrey 116
3 years ago
Edited 3 years ago

if only checks if points is bigger than 9 once solution: after the player added event add both loops as loops inside connects don't really play nice... put the if statement inside the loop and also the part where it adds 1 every 5 seconds

--player added part

while true do
    wait(5)
    Points.Value = Points.Value + 1
    if Points.Value > 9 then
        Rank.Value = "Better"
    end
end
Ad
Log in to vote
0
Answered by 3 years ago

For your case specifically, do..

while wait() do
    if Points.Value > 9 then
            Rank.Value = "Better"
    end
end

Answer this question