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

How do I change a players team and reset them when they click a GUI button?

Asked by 3 years ago

I'm trying to make it where the player returns to the "lobby". Meaning they need to change team to "lobby" and then reset so they spawn back. I've tried multiple times but they never work. Here is the code I'm currently using for the button:

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    plr.Team = "Lobby"
    plr.TeamColor = "Dark stone grey"
    plr.Health = 0
end)

(I have a feeling that I'm not defining/calling the player correctly)

Here's the code I tried using a method from this site:

local plr = game.Players.LocalPlayer.Name
repeat wait() until plr.Character
local chr = plr.Character
local hum = chr:WaitForChild("Humanoid")


script.Parent.MouseButton1Click:Connect(function()
    plr.Team = "Lobby"
    plr.TeamColor = "Dark stone grey"
    hum.Health = 0
end)
0
Is this in a LocalScript? Oh, and the second script won't work. Stick to the first one. DesertusX 435 — 3y
0
this is a localscript User#37681 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    plr.Team = "Lobby"
    plr.TeamColor = "Dark stone grey"
    plr.Character.Health = 0
end)
0
I've tried this but it only changes the team, and doesn't reset/kill the player. User#37681 0 — 3y
0
oh NoobPowerPlayzz 15 — 3y
Ad

Answer this question