Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Team Change GUI, Generalize Player?

Asked by 7 years ago

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!

1 answer

Log in to vote
0
Answered by 7 years ago

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)

0
Also, as a side note, since you already killed the player you don't really need "Player:LoadCharacter()" however you may have your own reasons so I decided to leave that line in for you. GoldenCosmo 64 — 7y
0
thanks so much, I didn't know about that, and that will be really helpful! FlippinAwesomeCrew 62 — 7y
0
Don't forget to accept the answer if it works, thanks and good luck! :-) GoldenCosmo 64 — 7y
Ad

Answer this question