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! :)))
game.workspace.players.playersIngame.Changed:connect(function(initialstart)
wait (5)
local playersIngame = game.workspace.players.playersIngame.Value
local children = game.Players:GetChildren()
if playersIngame >= 2
and playersAlive == 0 then
print ('The first game needs to be started')
workspace.mapsIngame:ClearAllChildren()
print ('First round initialized')
wait (initaltime)
print ('Loading new map')
for i,v in pairs(Maps) do
if randomMap == i then
storage = game:GetService('ReplicatedStorage')
local map = storage.Maps:WaitForChild(v):Clone()
map.Parent = workspace.mapsIngame
print ('Map loaded')
wait (initaltime)
print ('Changing teams')
for index, child in pairs(game.Players:GetChildren()) do
child.TeamColor = BrickColor.new("Really black")
wait (initaltime)
print ('Teleporting players and resetting values')
local a = game.Players:GetChildren()
for _,v in pairs (a) do
if v.Character then
v.Character.Torso.CFrame = CFrame.new(Vector3.new(math.random(1,100),math.random(1,100),math.random(1,100)),v.Character.Torso.Position)
playersAlive = playersIngame
print ('Let the games begin')
end
end
end
end
end
end
end)

4 comments
2 questions, what exactly is players.PlayersIngame? Also lines 20 and 26 and 28 look suspicious to me.
That's two of the exact question... -_-, To me it's a IntValue or NumberValue with a value of the current players in the game.
v.Character.Head.Cframe = ... instead of v.Character.Torso.CFrame = ... at line 27 its because you are r6 and your friend is r15 you can also chang your game settings to morph to r6
you can get this to work with r15 and r6 you'd probably use something like [if v.Character:FindFirstChild("Torso") or v.Character:FindFirstChild("LowerTorso") then]