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

How do you use RemoteFunctions properly in a GUI?

Asked by 9 years ago

I'm trying not to insert pieces of code into SH, one simply because I'm trying to make a game and I don't need large sections of the code available on a free website and another that the involved code is spread throughout several different places and would be quite difficult to coherently display here. ;D

Essentially, I'm building a fairly standard game with changing modes based on a timer. I've done this quite a few times but this time I decided to be a bit cooler and build the whole thing with modular scripting and FilteringEnabled. I have run into some slight issues. :/

I have a hierarchy like this:

Workspace
-->GlobalAssets
----->MainScripts
----->Modes
----->Core
Lighting
-->Guis
-->Tools

I've been able to make the switch to FilteringEnabled tools fairly seamlessly but I've encountered problems with the GUIs. A libary function (in loose pseudo code) does the following

for each player
copy gui into playergui
end

copy gui into startergui

I'm currently trying to use two GUIs, one displays a message and the other has a changeable picture. I've implemented RemoteFunctions to allow the server to control the guis through LocalScripts, but somehow when the GUI is copied this way there's been some minor problems.

  1. Destroying the GUI from the server required extra syncing (ie, server thinks a gui is deleted from a player when its not.)
  2. RemoteFunctions sometimes will simply not respond to input from the server even when their setup perfectly. I have one LocalScript in two guis with the exact same contents and object structure inserted into the player in identical ways and then interfaced by the server identically. Ridiculously, one responds to the input with a printout and the other does not (go figure).

What I need: 1. A fix for my current setup (not expecting this since my description is rather vague yet verbose) 2. What general guideline for manipulating 2D GUIs with RemoteFunctions and FilteringEnabled should I use?

Sorry for an extremely TL;DR explanation for a difficult problem, it just has me stumped.

0
Sorry for not being succinct enough. m27frogy 0 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You're right about this being quite vague, so I can't really give 100% issue solving answer.

First of all, try to use RemoteEvents for most of things, and if you must have it to return something, only then use RemoteFunctions. Mainly because RemoteFunctions are slower than events, and for command issuing there is no need for that waste of latency.

And as for controlling GUIs, I'd recommend you to have system that listens to all kinds of commands sent from server, and have a function for each of that command, that would do the task you intended. Personally I send a command + table with arguments. So you can simply send event with argument {Command = "DisplayScore", Argument = {Score = 13, Team = "Red"}}. It's pretty simple this way.

0
I'll try to do this as I move forward, thanks! m27frogy 0 — 9y
0
I'll try keeping this in mind going forward, thanks. m27frogy 0 — 9y
Ad

Answer this question