local function ClearArena()
workspace.Arena.Map:ClearAllChildren()
workspace.Arena.Characters:ClearAllChildren()
for _, player in ipairs(Players:GetPlayers()) do
-- Reset team
player.Team = game.Teams:FindFirstChild("Lobby")
player.Backpack:ClearAllChildren()
for i, v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
v:Destroy()
end
end
if player.Character then
player:LoadCharacter()
task.wait(0.1)
end
end
Are there any errors in the output from Roblox scripts that could relate to this issue?
If you store players’ characters in workspace.Arena.Characters, then why do you destroy their character when you respawn them anyway? This could be the issue. Try removing the line and see how it behaves.
Also some other things I find redundant in this code:
Looping through the character and destroying tools, but you respawn them anyway.
Doing FIndFirstChild() on a team. If it’s premade in Studio and not tampered with scripts on runtime, then it’ll 100% be there, so you can use the . method.
Checking if player exists before loading. If you destroy the character then check it before respawning, how/are they even respawning in the first place?
task.wait(0.1)
LoadCharacter() already clears the backpack (See docs)
Overall, it could just be these minor things causing the issue. This is my revision of your code:
local function ClearArena()
workspace.Arena.Map:ClearAllChildren()
for _, player in Players:GetPlayers() do
player.Team = game.Teams.Lobby
player:LoadCharacter()
end
end