I am trying to make a switch team script and I am at the last part where I have to get the script to go invisible but it seems wherever I put the last part of code it doesn't work.
Script:
game.StarterGui.TeamSwitchGui.MainFrame.Visible = true
local TC = Instance.new("RemoteEvent")
TC.Name = "TeamChanger"
TC.Parent = game.ReplicatedStorage
TC.OnServerEvent:Connect(function(Player, TeamName)
Player.Team = game.Teams[TeamName]
game.StarterGui.TeamSwitchGui.MainFrame.Visible = false -----Part that is not working
Player:LoadCharacter()
end)
Please help.

2 comments
Where's the script?
This is just to make it invisible.