Alarm system design help

Hello, devs

I have an alarm class working on the client side, (sound, light, material) would change upon activation on the client side only, cuz I don’t want to burden the server. Currently my alarm class is listening for changes of BoolValue in ReplicatedStorage.

I wonder if I should store the BoolValue in ServerStorage and when the value is changed, a server script would fire a remote event to all clients.

Which way is more efficient and faster?

Thank you!

1 Like

If nothing is listening to the BoolValue’s value on the server, then you don’t need it. Just fire straight to the clients.

If the alarm does something on the server apart from firing to clients, then I would opt for a ModuleScript.

local Alarm = {}

function Alarm:fire()
   -- ... server code that does something
    remoteEvent:FireAllClients()
end

return Alarm

So I can’t really give an answer to your question “Which way is more efficient and faster?” since you haven’t explained the system on the server side of things.

Like what is triggering the alarm, what other scripts are involved in the system, etc. But if you could elaborate more, I’d be more than happy to help.

But overall, I don’t think you need to worry about performance on this scale. About any approach should be a minute difference.

Also, I never use ValueObjects and rarely use attributes since ModuleScripts and signals exist to keep your whole codebase, well, in code.

1 Like

Thank you very much for the info!

On the server side, when BaseCode is a specific value, all doors will be locked. Currently I don’t have many things on the server react to this value. Maybe a warning gui on all screens which I think will be done on client side only.

It’s basically a base alarm system, I forget that it’s an IntValue and not a BoolValue. This value has a name “BaseCode”. 0 is a normal state, 1 is the most critical, 8 is the least critical. Alarm is triggered via button (ClickDetector) or Terminal (SurfaceGui textbutton) MouseButton1Click.

I’m a little old-fashioned because I occasionally read updates and I tends to work on the game in bursts instead of continously dev + ValueObjects are visually helpful for me.

I end up using Packet following this architecture.


CONS:

  • You have to sync alarm states for player who joined after the remote is fired.
  • If you have streaming enabled, alarms those are streamed in AFTER the event is fired to clients won’t receive the signal.

SOLUTIONS:
I store the base code value/info in the client module, in OnClientEvent I fire a client-sided Signal (bindable event replacement) to activate alarms.

Yeah this is pretty confusing so I advised you to use ObjectValues or attributes as alternatives.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.