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

For loop problem?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

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
0
What is the goal of this script? BlackJPI 2658 — 8y
0
To teleport the players to a brick and to get the number of players as a NumberValue NotSoNorm 777 — 8y

2 answers

Log in to vote
3
Answered by
saenae 318 Moderation Voter
8 years ago

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.

0
you won't run the 'for' loop* saenae 318 — 8y
0
correct! ImageLabel 1541 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

I agree with saenae on that one

Answer this question