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

For loop broken, used to work in a while true do loop, isn't working at all now?

Asked by
Uzuntu 6
7 years ago

I was working on a script and I had a for loop that gave the player a value, but since it was in a while true do loop it just created values endlessly. I took it out of the loop, and now it doesn't work at all, even when I put it back in the loop. Anything outside of the for loop works, so I know it's something wrong with the for loop.

Here's my code:

local PlayersAlive = Instance.new("Folder")
PlayersAlive.Parent = game.ServerStorage
PlayersAlive.Name = "PlayersAlive"

local ReadyList = Instance.new("NumberValue")
            ReadyList.Parent = game.ServerStorage
            ReadyList.Name = "ReadyList"

local PlayerList = game.Players:GetPlayers()

    for i, Player in pairs(PlayerList) do
        print 'WORK'
        local ValueFolder = Player:WaitForChild("ValueFolder")
        if ValueFolder.Ready.Value == false then
            print "false"
        else
            print "true"
            local PlayerName = Instance.new("StringValue")
            PlayerName.Parent = game.ServerStorage.PlayersAlive
            PlayerName.Name = Player.Name
            PlayerName.Value = Player.Name
        end
    end
0
Make sure you have added a ValueFolder within the Player. StoleYourClothes 105 — 7y
0
I have though, i.e. my reply to the answer below. Uzuntu 6 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

It doesn’t look like you inserted a “ValueFolder” in the player, I might just be blind but that looks like it is the error.

0
The ValueFolder is there, just everything I try to insert in the for loop isn't. Uzuntu 6 — 7y
Ad

Answer this question