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

Filtering Enabled GUI problems?

Asked by 8 years ago

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?

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

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

Ad

Answer this question