Why is my Teamchanging/Teleportation loop malfunctioning?
This is the main script for my first game project. Everything works fine up until the changing teams and teleportation/section. When play testing in a local server everything seems to be in order, however when I bring a friend in to test in play mode only I am teleported and teamchanged. Thank you for your help! :)))
01 | game.workspace.players.playersIngame.Changed:connect( function (initialstart) |
03 | local playersIngame = game.workspace.players.playersIngame.Value |
04 | local children = game.Players:GetChildren() |
06 | and playersAlive = = 0 then |
07 | print ( 'The first game needs to be started' ) |
08 | workspace.mapsIngame:ClearAllChildren() |
09 | print ( 'First round initialized' ) |
11 | print ( 'Loading new map' ) |
12 | for i,v in pairs (Maps) do |
13 | if randomMap = = i then |
14 | storage = game:GetService( 'ReplicatedStorage' ) |
15 | local map = storage.Maps:WaitForChild(v):Clone() |
16 | map.Parent = workspace.mapsIngame |
19 | print ( 'Changing teams' ) |
20 | for index, child in pairs (game.Players:GetChildren()) do |
21 | child.TeamColor = BrickColor.new( "Really black" ) |
23 | print ( 'Teleporting players and resetting values' ) |
24 | local a = game.Players:GetChildren() |
25 | for _,v in pairs (a) do |
27 | v.Character.Torso.CFrame = CFrame.new(Vector 3. new(math.random( 1 , 100 ),math.random( 1 , 100 ),math.random( 1 , 100 )),v.Character.Torso.Position) |
28 | playersAlive = playersIngame |
29 | print ( 'Let the games begin' ) |