RemoteServer
script.RecolorGUI:FireAllClients()
RemoteClient
PlrService = game:GetService("Players") plr = game.Players.LocalPlayer char = plr.Character PlrGui = game.Players.LocalPlayer.PlayerGui PlrGui:WaitForChild("ScreenGui").TextButton.MouseButton1Click:connect(function() game.Workspace.RemoteServer.RecolorGUI.OnClientEvent:connect(function() PlrGui:WaitForChild("ScreenGui").TextButton.BackgroundColor3 = Color3.new(math.random(), math.random(), math.random()) end) end)
When I try to click the button in a server with 2 players, it doesn't change color, and in play mode It changes color, but only 1 time, and not more. Any fix?
Problem:
script.RecolorGUI:FireAllClients()
will run as soon as the game begins. But line 13 - where you actually connect the event - won't run when the game begins. It runs when you click the gui. Therefore, although you're firing the clients, they won't actually be listening for anything, and therefore won't respond (by executing the code).
Solution:
It's a bit confusing on what you're actually trying to do. If you just want a gui to change color when you click it, you don't need to use remotes at all. You can just handle it locally.
button.MouseButton1Click:connect(function() gui.BackgroundColor3 = Color3.new(math.random(), math.random(), math.random()) end)
Or perhaps you want it to change color every time you fire a remote.
remote.OnClientEvent:connect(function() gui.BackgroundColor3 = Color3.new(math.random(), math.random(), math.random()) end)
Please comment with clarification if I'm still missing your purpose