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

For loop problem?

This script won't work and won't give off any errors, I used prints and it errors at the for loop????

s = game.Workspace.Spawns.StartingPlace
p = game.Players:GetChildren()

while true do
	wait(10)
for i = 1, #p do  --Where the print didn't continue
	script.Parent.NumberOfPeopleInGame.Value = #p
if game.Workspace:findFirstChild(p[i].Name) then 
p[i].Character.Torso.CFrame = s.CFrame * CFrame.new(math.random(-3,3),8,math.random(-3,3)) 
end
end
end

2 comments

0

What is the goal of this script?

0

To teleport the players to a brick and to get the number of players as a NumberValue

2 answers

I'm not sure when you're running the code, but your 'p' value will never update if it's not in the loop. At the start of the game, your '#p' will be 0, and thus, you won't run the loop. However, if you tried running it again whilst in-server and it didn't work, then I haven't a clue why.

2 comments

0

you won't run the 'for' loop*

0

correct!

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