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
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)
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)
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)