Intermission system teleports only 1 person at a time

Perhaps i am doing something wrong, i have a intermission system that works very well with 1 player,but when i try it with 2 players at once it only teleports one of them.

I have no clue of why this is happening and i got no errors so far. Any help would be appreciated.

Code:

StartGame.Changed:Connect(function()
	if StartGame.Value == true then
	
		for i, Player in pairs(game.Players:GetPlayers()) do

			local Character = Player.Character
			local hum = Character:WaitForChild("Humanoid")
			local InGame = Player:FindFirstChild("InGame")
			local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

			local emptySpawn = spawnPlayers(workspace.Map.Spawns)

			if emptySpawn then
				
				hum.WalkSpeed = 0
				hum.JumpPower = 0
				InGame.Value = true
				
				workspace.SFX.Start:Play()
				HumanoidRootPart.CFrame = workspace.Map.Lobby.CFrame
				workspace.SFX.Ambient.Playing = true
				
				print(emptySpawn.CFrame)
				
				HumanoidRootPart.CFrame = emptySpawn.CFrame
				
				workspace.SFX.Ambient.Playing = true

				Status.Value = "Before we start, rules are simple."

				wait(3)

				Status.Value = "You have 60 seconds to vote for someone."

				wait(2)

				Status.Value = "The player with the most votes is eliminated."

				wait(3)				

				Status.Value = "Good luck."

				wait(1)

				game.ReplicatedStorage.StartVote.Value = true
				game.ReplicatedStorage.GameStarted.Value = true
				startLoop()
				
				break
				
			end
		end
	end
end)

Also the emptySpawn finder code:

local function spawnPlayers(spawnFolder)
	
	local chosenSpawn
	
	repeat
		chosenSpawn = spawnFolder:GetChildren()[math.random(1,#spawnFolder:GetChildren())]
	until chosenSpawn.IsUsed.Value == false
	
	chosenSpawn.IsUsed.Value = true
	
	return chosenSpawn
end
1 Like

this probably happens because you break the for loop before it could cycle to the other player

You have a break which means it’ll only go thru one player

1 Like

i have removed the break and still the same problems

1 Like

try this

local Character = Player.Character
local hum = Character:WaitForChild(“Humanoid”)
local InGame = Player:FindFirstChild(“InGame”)
local HumanoidRootPart = Character:WaitForChild(“HumanoidRootPart”)
local emptySpawn = spawnPlayers(workspace.Map.Spawns)
if emptySpawn then
hum.WalkSpeed = 0
hum.JumpPower = 0
InGame.Value = true
workspace.SFX.Start:Play()
HumanoidRootPart.CFrame = workspace.Map.Lobby.CFrame
workspace.SFX.Ambient.Playing = true
print(emptySpawn.CFrame)
HumanoidRootPart.CFrame = emptySpawn.CFrame
workspace.SFX.Ambient.Playing = true
end
end
if emptySpawn then
Status.Value = “Before we start, rules are simple.”
wait(3)
Status.Value = “You have 60 seconds to vote for someone.”
wait(2)
Status.Value = “The player with the most votes is eliminated.”
wait(3)
Status.Value = “Good luck.”
wait(1)
game.ReplicatedStorage.StartVote.Value = true
game.ReplicatedStorage.GameStarted.Value = true
startLoop()
end
end
end)

did not work

char limitttttt

1 Like

try ths

StartGame.Changed:Connect(function()
	if StartGame.Value == true then
	local emptySpawn = spawnPlayers(workspace.Map.Spawns)
		for i, Player in pairs(game.Players:GetPlayers()) do

			local Character = Player.Character
			local hum = Character:WaitForChild("Humanoid")
			local InGame = Player:FindFirstChild("InGame")
			local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")


			if emptySpawn then
				
				hum.WalkSpeed = 0
				hum.JumpPower = 0
				InGame.Value = true
				

				HumanoidRootPart.CFrame = workspace.Map.Lobby.CFrame
				workspace.SFX.Ambient.Playing = true
				
				print(emptySpawn.CFrame)
				
				HumanoidRootPart.CFrame = emptySpawn.CFrame
				end
	 		 end
if emptySpawn then
			InGame.Value = true
			workspace.SFX.Start:Play()
	 workspace.SFX.Ambient.Playing = true
				Status.Value = "Before we start, rules are simple."

				wait(3)

				Status.Value = "You have 60 seconds to vote for someone."

				wait(2)

				Status.Value = "The player with the most votes is eliminated."

				wait(3)				

				Status.Value = "Good luck."

				wait(1)

				game.ReplicatedStorage.StartVote.Value = true
				game.ReplicatedStorage.GameStarted.Value = true
				startLoop()
				

				
end
	end
end)

still not working, it might be a problem with my emptyPlayer spawn script

This is happening cause you are teleporting the player and setting Status.Value and waiting in the same loop

Try this:

StartGame.Changed:Connect(function()
	if StartGame.Value == true then

		for i, Player in pairs(game.Players:GetPlayers()) do

			local Character = Player.Character
			local hum = Character:WaitForChild("Humanoid")
			local InGame = Player:FindFirstChild("InGame")
			local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

			local emptySpawn = spawnPlayers(workspace.Map.Spawns)

			if emptySpawn then

				hum.WalkSpeed = 0
				hum.JumpPower = 0
				InGame.Value = true
				HumanoidRootPart.CFrame = workspace.Map.Lobby.CFrame
				
				print(emptySpawn.CFrame)

				HumanoidRootPart.CFrame = emptySpawn.CFrame
				
			end
		end
		
		
		workspace.SFX.Start:Play()
		workspace.SFX.Ambient.Playing = true
		
		Status.Value = "Before we start, rules are simple."

		wait(3)

		Status.Value = "You have 60 seconds to vote for someone."

		wait(2)

		Status.Value = "The player with the most votes is eliminated."

		wait(3)				

		Status.Value = "Good luck."

		wait(1)
		
		game.ReplicatedStorage.StartVote.Value = true
		game.ReplicatedStorage.GameStarted.Value = true
		startLoop()
	end
end)
2 Likes

Ah thank you so much! I didn’t knew that was a thing

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.