So I am trying to make it so when you click a button it changes your team.
I get this error
local button = script.Parent.Frame.Button
local mainframe = script.Parent.TeamchangerUI
local Team1 = mainframe:WaitForChild("Team1")
local Team2 = mainframe:WaitForChild("Team2")
local team2 = game.Teams["Team 2"]
local team1 = game.Teams["Team 1"]
button.MouseButton1Click:Connect(function()
local mainframe = script.Parent.TeamchangerUI
if mainframe.Visible == true then
mainframe.Visible = false
print("Mainframe was closed")
elseif mainframe.Visible == false then
mainframe.Visible = true
print("Mainframe has been opened")
end
end)
Team1.MouseButton1Click:Connect(function(p)
local player = game.Players.LocalPlayer
player.Team = game:GetService("Teams")[team2]
end)
Team2.MouseButton1Click:Connect(function(p)
local player = game.Players.LocalPlayer
player.Team = game:GetService("Teams")[team1]
end)