Im new making team changer GUI and IDK how do I get the player and a event when the player clicked the button
local Teams = game:GetService('Teams')
if not Teams:FindFirstChild("Headquarters") then
local Team = Instance.new("Team")
Team.TeamColor = BrickColor.new('Gold')
Team.Name = "Headquarters"
Team.Parent = Teams
-- change the player team to the new team
else
-- if the team exist change the player team
end
Teams.ChildAdded:Connect(function(Team)
if Team.Name == "Headquarters" then
Team.PlayerRemoved:Connect(function()
if #Team:GetPlayers() == 0 then
Team:Destroy()
end
end)
end
end)