Hi scripters, I've made a small section of code that is expected to change a player's team when they die. I don't feel like using the pre-coded scripts that are available for purchase from the Library, since i want to figure this out myself. The problem is, when the Humanoid dies in my script, a few moments later the player changes team to Neutral, but instead it creates a new team called Neutral. Any advice?
local Character = script.Parent local Humanoid = Character.Humanoid local Player = Character.Name local FoundPlayer = game.Players:WaitForChild(Player) local Neutral = game.Teams.Neutral Humanoid.Died:connect(function() FoundPlayer.Team = Neutral end)
Advice is appreciated!
Assuming this is a Server Script,
Please make sure that you have Two Teams in the game.Teams
Folder before you start the game (the obvious exception being that the team is added while in-game --- if this is the case, please comment below and I will be happy to assist you with that)
One of these two Teams should be named "Neutral" and have its AutoAssignable Property set to false
, while the other Team (the name doesn't matter for this script) should have its AutoAssignable Property set to true
.
Upon testing, I found nothing wrong with your script's code, however, I suggest capitalizing "connect" to "Connect" as the lowercase is considered deprecated (although it will work at times)