Okay so I am trying to make it so if you press the button to change teams you reset and then you change teams. Here is the script:
function Click(mouse) script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright red") end script.Parent.MouseButton1Down:connect(Click)
I want to know how to make it reset your character when you click the button as well as change teams. Please help, thanks for reading this and double thanks if you make a comment or answer for this.
Assuming you are using a GUI button (TextButton or an ImageButton), you could just use a LocalScript to get the player and make life easier for yourself.
local player = game.Players.LocalPlayer --Get the LocalPlayer. function Click() player.TeamColor = BrickColor.new("Bright red") end script.Parent.MouseButton1Down:connect(Click)
Getting the player's character:
To make it so you can kill the player, you need access to the character. Fortunately, there's a property called Character
in every player that directs you to the player's character, so you can gain access to the humanoid and set it's health to 0.
To avoid errors, you could also use the WaitForChild
method to wait until the Humanoid becomes available.
local player = game.Players.LocalPlayer --Get the LocalPlayer. function Click() player.TeamColor = BrickColor.new("Bright red") player.Character:WaitForChild("Humanoid").Health = 0 end script.Parent.MouseButton1Down:connect(Click)
I hope my answer helped you. If it did, be sure to accept it so others know your question has been answered.