Need help for GUI scripting

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)

Use the Button.Activated or Button.MouseButton1Click event.

And how do I get the player and team it?

BlueTeamButton.Activated:Connect(JoinBlueTeam)
RedTeamButton.Activated:Connect(JoinRedTeam)

?

Nevermind I just need to found a solution