Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

0

Is this in a LocalScript? Oh, and the second script won't work. Stick to the first one.

0

this is a localscript

1 answer

local plr = game.Players.LocalPlayer

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

2 comments

0

I've tried this but it only changes the team, and doesn't reset/kill the player.

0

oh

This discussion is preserved as it was. New answers, comments, and votes are closed.