Hey all! Let me explain.
So I am making a system where if you shine a flashlight (not a tool, a literal built-in flashlight) at a doorway and if a monster is there, the monster will back off after the light was shined at them for x amount of time.
Since the flashlight functions (toggling on and off) are client-side (they are in StarterPlayerScripts) and the monster AI is server-side, I ended up creating a value in ReplicatedStorage that increases every frame the flashlight is on. When the monster appears, it’s reset to 0 and then it constantly checks if the value is higher than a specific constant.
However, since the increasing incorporates the delta
via RunService (I wanted to eliminate framerate differences), my only “solution” so far was to send a RemoteEvent every frame the light is on, passing the delta as a parameter. Sadly, I think this is extremely unoptimized, and probably a bad idea to do. Can anyone recommend some better alternatives to somehow make the delta time available to the server?