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

2 comments
Make sure you have added a ValueFolder within the Player.
I have though, i.e. my reply to the answer below.