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 4 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.

function Click(mouse)  
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("New Yeller") 
end 

script.Parent.MouseButton1Click:connect(Click) 

2 answers

Log in to vote
0
Answered by
Gojinhan 353 Moderation Voter
4 years ago
Edited 4 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:

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

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

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

instead of function click(mouse), try this.

    (name of button).Mouse1Click:Connect(function()
    script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("New Yeller")
    end

    script.Parent.MouseButton1Click:connect(function()

Answer this question