local player = game.Players:GetChildren() playersingame = 0 function onPlayerEntered(nP) playersingame = playersingame +1 end game.Players.ChildAdded:connect(onPlayerEntered) while playersingame > 0 do x = Instance.new("Hint",Workspace) x.Name = "GameStart" x.Text = "New game is starting." wait(1) x.Text = "New game is starting.." wait(1) x.Text = "New game is starting..." wait(1) x.Text = "Game in progress..." player[i].Character.MoveTo(Vector3.new(0.6, 0.59, 3.8)) end
It's supposed to create a Hint that tells you the game status, then, it's supposed to teleport all players to this position "0.6, 0.59, 3.8", yet it doesn't do any of that.
Your problem is player[i] does not work unless you have a variable named i, like in a for loop. Second, MoveTo() is a method, which means you much use :.Therefore, you can easily do this:
for i = 1,#player do player[i].Character:MoveTo(Vector3.new(0.6, 0.59, 3.8)) end
Please tab and space your code properly!
Your definition of player
(should be players
probably since it is a list) should happen immediately before doing the loop!
Otherwise there could be people who joined or left in the interim!
Also, your while
loop should probably always run, rather than have the condition that only run while there are players. If there were not players, then the loop would stop and never start again!
Instead we just check each loop that there are players.
In addition, you should check that the players have both a Character
!
Otherwise your script could error if someone is dead and it would stop working!
Also, MoveTo
is a method, so you use :
instead of .
on it.
All of this is in addition to Perci1's addition of the for
loop
while true do wait(1); local players = game.Players:GetChildren() if #players > 0 then x = Instance.new("Hint",Workspace) x.Name = "GameStart" x.Text = "New game is starting." wait(1) x.Text = "New game is starting.." wait(1) x.Text = "New game is starting..." wait(1) x.Text = "Game in progress..." for i = 1, #players do if players[i].Character then players[i].Character:MoveTo(Vector3.new(0.6, 0.59, 3.8)) end end end end