I know about the Humanoid.Died function but I don't really understand how I can make them switch teams after they die. I tried using this script and it doesn't work...
local lobby = script.Parent.Lobby local players = script.Parent.Players if game.Players.LocalPlayer.Team == players and game.Players.LocalPlayer.Humanoid.Died then game.Players.LocalPlayer.Team = lobby end
assuming this is a local script
Well, the Died event isn't a function but rather an event, which means the current way you are doing things would error
Because it is an event, it must be formatted like :
humanoid.Died:Connect(function() ... end)
rather than what you did.
A couple of other things to note here :
Humanoid is a child of the player's character, not of the player itself.
Modifying the player's team on a local script, which doesn't work with FE.
You placed a local script outside the player/character which means it doesn't run.
With all that said, here is the finished product.
for _,plr in pairs(game.Players:GetPlayers()) do local char = plr.Character or plr.CharacterAdded:Wait() local hum = char.Humanoid hum.Died:Connect(function() if plr.Team == game.Teams.Players then plr.Team = game.Teams.Lobby end end) end
Notice that this shouldn't be on a local script, which means the script doesn't have access to the local player, and since the use of RemoteEvents could be exploited in this case, it is best to handle everything on a server script.
Hopefully this helped!
btw, this isn't a complete script (obviously)
Here is a quick instructional guild on how to make a user switch teams on death. (Note: Skip to step 3.)
First you need to add TeamService. You can do so by going to the "MODEL" tab on the top of roblox studio and looking to the right for a gear icon with the word "Services" under it. Click it and click "Teams". Then press insert.
Next you need to add a team. You can add one by clicking the plus icon that appears in the explorer over the Teams folder. Then insert a "Team". I will be naming my team "Dead" and making its color "Really red".
Now you need to put a script into "ServerScriptService" and put the following code into it.
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() player.Team = game.Teams.Dead end) end) end)
Additional Notes: -It may happen that the player spawns in automatically on the Dead team. To fix that add a neutral team.