So basically I have a team called Lobby that is auto assignable when the player dies, but for a specific game mode in my game I want to change the player’s team to Playing when he dies so that he respawns in the Playing team spawns, what would be the best and most efficient way to do this? I have tried using the humanoid.Died function and changing the player’s team after doing player.CharacterAdded:Wait(), but sometimes it works and others it doesn’t, is there a better way to do this?
This is what I’m currently using that actually never works rip:
humanoid.Died:Connect(function()
if deaddebounce then return end
deaddebounce = true
Player.CharacterAdded:Connect(function()
char = Player.Character or Player.CharacterAdded:Wait()
--Here's where's not working
Player.Team = Playingteam
wait(2)
if hassword == false then
hassword = true
local swordvalue = Player:WaitForChild("ToolStats"):WaitForChild("Sword").Value
local plrsword = ReplicatedStorage:WaitForChild("BuyableItems"):FindFirstChild(swordvalue):Clone()
plrsword.Parent = Player.Backpack
end
end)
end)
Could anybody help me with this?