I'm making a team change GUI, but the problem is when you change your team, in the game, you don't respawn you just stay where you are and change teams, until you die. So I made it so that when you change your team, you die, but I can't figure out how to generalize a player. Here's the script:
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() player.TeamColor = BrickColor.new("Bright red") game.Workspace.player.Name.Humanoid.Health = 0 player:LoadCharacter() end)
but, that player.Name
won't work can you please help?
Thank you!
There's this neat feature in ROBLOX you can use to find the character of already defined players, you simply just have to add .Character. For instance, say you want to kill a player 10 seconds after they join, you'll need to put a local script in PlayerStarterScripts that waits 10 seconds, then you make a variable that defines the player (plr = game.Players.LocalPlayer) then you simply find the character, the humanoid, and you set the health to 0, which would be plr.Character.Humanoid.Health = 0, let me edit your script and you let me know if it works for you.
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() player.TeamColor = BrickColor.new("Bright red") player.Character.Humanoid.Health = 0 player:LoadCharacter() end)