I tried making a script where if you click a GUI button it changes your team, but it doesn't do anything. Here is the script.
1 | function Click(mouse) |
2 | script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new( "New Yeller" ) |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Click:connect(Click) |
Hey in the future, please specify what the hell those 5 .Parent's lead to. Thanks, anyway don't bother doing it on the client. You should fire a remote instead.
The script under the gui button:
1 | script.Parent.MouseButton 1 Down:Connect( function () |
2 | game.ReplicatedStorage:WaitForChild( "TeamEvent" , 3 ):FireServer() |
3 | end ) |
And make a script in serverscriptservice, here would be the content of that script:
1 | local desiredteam = whateverthehellyouwant |
2 | -- an example for the above could be like game.Teams.Yellow |
3 | local r = Instance.new( "RemoteEvent" ) |
4 | r.Parent = game.ReplicatedStorage |
5 | r.OnServerEvent:Connect( function (p) |
6 | p.Team = desiredteam |
7 | end ) |
instead of function click(mouse), try this.
1 | (name of button).Mouse 1 Click:Connect( function () |
2 | script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new( "New Yeller" ) |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Click:connect( function () |