When the player is teleported back to the lobby in my round-based game, the sword in their inventory needs to be taken away.
How can I do that for all players?
I've tried looping through or removing it when they touch the lobby floor, and it DID remove it, but then they couldn't get it back because it was constantly removing it.
Code:
while true do
wait(1)
if gameMode == 1 then -- Intermission
-- set the intermissionTime to the intTimerlabel text ON BOTH LABELS
interTimerLabel.Text = tostring(intermissionTime)
interTimerLabel2.Text = tostring(intermissionTime)
-- decrement intermissionTime
intermissionTime = intermissionTime - 1
-- if it hits 0, set it back to 30, switch gamemode, and teleport players
if intermissionTime < 1 then
-- change the current gameMode to round in progress (2)
gameMode = 2
intermissionTime = 31
-- Give all the players in the game swords
for _,player in ipairs(game.Players:getChildren()) do
local tool = game.ReplicatedStorage.ClassicSword:Clone()
tool.Parent = player.Backpack
end
-- teleport all the players to the arena
target = CFrame.new(14, 1.715, 62.3) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
elseif gameMode == 2 then -- Match in progress
-- set the arenaTimer text to matchTime
arenaTimerLabel.Text = tostring(matchTime)
-- decrement matchTime by 1
matchTime = matchTime - 1
-- if matchTime gets to 0, set it back to 180, switch gamemode, and teleport players
if matchTime < 1 then
-- change gamemode to intermission
gameMode = 1
intermissionTime = 31
matchTime = 181
-- sword is removed when the player touches the lobby floor
-- teleport all the players to the LOBBY
target = CFrame.new(24.5, 57.305, 50.4) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
end
end

2 comments
Because it's a while loop, it constantly removes the tools. You should add a "break" when needed.
Where would I "break"?