Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My team change gui doesn't work when I click?

Asked by 5 years ago

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.

1function Click(mouse) 
2script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("New Yeller")
3end
4 
5script.Parent.MouseButton1Click:connect(Click)

2 answers

Log in to vote
0
Answered by
Gojinhan 353 Moderation Voter
5 years ago
Edited 5 years ago

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:

1script.Parent.MouseButton1Down:Connect(function()
2   game.ReplicatedStorage:WaitForChild("TeamEvent", 3):FireServer()
3end)

And make a script in serverscriptservice, here would be the content of that script:

1local desiredteam = whateverthehellyouwant
2-- an example for the above could be like game.Teams.Yellow
3local r = Instance.new("RemoteEvent")
4r.Parent = game.ReplicatedStorage
5r.OnServerEvent:Connect(function(p)
6   p.Team = desiredteam
7end)
Ad
Log in to vote
0
Answered by 5 years ago

instead of function click(mouse), try this.

1(name of button).Mouse1Click:Connect(function()
2script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("New Yeller")
3end
4 
5script.Parent.MouseButton1Click:connect(function()

Answer this question