Server Context script, but need to spawn object?

There are objects that are spawned in my game that explode when coming into contact with players.

I have the script that handles the detection and damage in a Server Context. The problem is, since it is a Server Context script, I can't spawn the effect that happens when it explodes.

Is there a way around this? Is it possible to have a Server Context script that handles "stuff", but then when that "stuff" happens, somehow spawn an object at that position(the explosion effect)? Can I have the Server Context script cause another script(non Server Context) to run?

There are a few ways to do this. In any case you'll spawn the Effect with a ClientContext Script.
Then you can either detect the collision both in the Server and Client, where the later is going to handle the important stuff and the former just trigger an effect.
Or, you can left everything to the Server and then Broadcast an Event to the Client so it knows it's time to spawn the Effect.

Thanks :slight_smile: I got the broadcast way to work.

I'm curious about something though ..

With lag considerations(I know this is a pretty minor event though), is it better to have OnBeginOverlap in both client and server scripts or is it better to broadcast from the server script to the client context script? I'm wondering which way has more potential to have delay issues between the server "stuff" and the client audio/visuals?

Not sure if the "size" of the Event is something to worrie. But there is a limit of 10 events per second per player. And that's why you have to use Events very carefully.
In fact, I try to avoid them unless it's absolutly necessary.

Bear in mind I'm not expert. But I think the general consense is to have everything you can, in the Client. And only the necesary thing in the Server.
So detecting the same collision both in the Client and in the Server, using the client one to Spawn an Effect and the Server one to process something like physics, makes sense to me.