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 4 years ago
01game.Players.PlayerAdded:Connect(function(players)
02    local folder = Instance.new("Folder",players)
03    folder.Name = "leaderstats"
04    local Points = Instance.new("IntValue",folder)
05    Points.Value = 0
06    Points.Name = "Points"
07    local Rank = Instance.new("StringValue",folder)
08    Rank.Name = "Amateur"
09    while true do
10        wait(5)
11        Points.Value = Points.Value + 1
12    end
13    if Points.Value > 9 then
14        Rank.Value = "Better"
15    end
16end)

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
4 years ago
Edited 4 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

1--player added part
2 
3while true do
4    wait(5)
5    Points.Value = Points.Value + 1
6    if Points.Value > 9 then
7        Rank.Value = "Better"
8    end
9end
Ad
Log in to vote
0
Answered by 4 years ago

For your case specifically, do..

1while wait() do
2    if Points.Value > 9 then
3            Rank.Value = "Better"
4    end
5end

Answer this question