Make your Own Global Events

I’ve encountered many people who have problems that could be solved with this, I haven’t tested it, so I don’t know if it works lol. (Look at the end). Keep in mind this is for tasks that don’t need to be executed immediately, and can wait some seconds.

Basically, let’s say you want to create an sphere when the player presses interact.
And you want it to be handled by the server, so that if the player disconnects, you still have the control over it.

First let’s define the parameters for the event.

Event( position : Vector, effectType : Number )

So a position of type Vector and an effectType of type Number which will give us the information of what type you want the effect to be.

All of our events will be handled by a global array (a global variable that holds an array) of our choosing, I will refer to it as Events.

So to dispatch our event, we simply

Modify Global Variable ( Events, Append To Array, position )
Modify Global Variable ( Events, Append To Array, effectType )

here position could be Position Of(Event Player) and effectType could be Sphere, since we can’t have that as a Value we could say 1 for example equals Sphere.

So now it gets appended to the back of Events.

the code to handle the events is

event
 Ongoing - Global
conditions
  Count Of(Events) > 0
actions

  // we only said 1 equals Sphere so we’ll ignore the other types, otherwise this code will be too long

  // here we check if Events[ 1 ] (effectType) equals 1
  Skip if( Value In Array( Events, 1 ) != 1, 1);
    Create Effect (
    All Players( Team(All) ),
    Sphere,
    White,
    Value In Array ( Events, 0 ),
     // here Events[ 0 ] is the position parameter
    1,
    Visible To, Position, and Radius
   );

 // removes the top of the array
 Set Global Variable (Events, Slice Array( 2, 999999999 ) );
 // starts at 2 because there’s two parameters


 Wait(0.01);
 Loop If Condition is True()

Double slash ( // ) are comments, not part of the code, they’re meant to explain what’s happening.

Basically we continously execute the head of Events and then delete it.

so the structure is like this

EXECUTE ACTIONS WITH PARAMETERS
DELETE PARAMETERS FROM EVENTS
REPEAT IF EVENTS IS NOT EMPTY

and we are treating the Array as a Queue. A data structure, if anyone wants to look for information about it, that’s how it is called.

You could have any amount of arguments, and also you could do it in the other direction as well, from global to player or player to player.
We can do many other things as well, for example, we could add the created effect to a global array, or we could take more arguments to set the other parameters, as well as adding more skip ifs to add compatibility for other types of effect. If anyone has any questions I can answer them. also if someone can tell me if it works it would be nice lol.
It works here’s the code
4J3D1