Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

0

Make sure you have added a ValueFolder within the Player.

0

I have though, i.e. my reply to the answer below.

1 answer

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.

1 comment

0

The ValueFolder is there, just everything I try to insert in the for loop isn't.

This discussion is preserved as it was. New answers, comments, and votes are closed.