local TeamImage = script.Parent.Parent
local Team1Button = script.Parent
function onClick(player)
player.TeamColor = BrickColor.new("Parsley green")
TeamImage.Visible = false
end
Team1Button.MouseButton1Click:Connect(onClick)
Because the .MouseButton1Click event does not provide the player who clicked as a parameter. Just define local player = game:GetService("Players").LocalPlayer at the top of your script.
Read Vong’s article / talk to me in DM if you have questions about it
And here’s how you’d do it with a server script inside the gui:
I put the script directly inside of the gui as you can see here:
The script is inside a gui inside the player so that’s how we get the player. It is a normal script so it’s changing the team on the server (for everyone) instead of locally (only changing it on your computer) in a local script.
Here’s the script:
local teams = game:GetService("Teams")
local gui = script.Parent
local player = gui.Parent.Parent
local TeamImage = gui.Frame.TeamSelectImage
local Team1Button = TeamImage.Team1Button
function onClick()
player.Team = game.Teams["MyTeamName"]
TeamImage.Visible = false
end
Team1Button.MouseButton1Click:Connect(function()
onClick()
end)