Skip to main content
Inspiring
June 22, 2025
Question

Can we send an entity to local script?

If I have a default script that needs to send or set an entity on a local script, is there a simple way.

Entity can't be serialized, so that means transfer ownership and network commands likely can't send entity.

One work around I could think of is name the entity using a UUID, then we can use both transfer ownership and network commands to transfer UUID and then get component by name. 

Other work around is using asset that has the default script and a local script that has reference to default script, so you change ownership to player and now you have local reference to default script entity. 

 

Any other ways, or better ways. Like default script spawns asset and you want to send the entity or asset to a local script owned by player.

2 replies

Inspiring
June 22, 2025

I don't know if this is a good solution or not, but you could put a local script on the entity that the server spawns, have the server set the owner to the player for the spawned in entity, and then have that local script on the spawned in entity send a local event with a reference to itself to the local script you want to know about it in preStart/start if it isn't server owned.

Inspiring
June 23, 2025

Not sure if I am crazy, but tested things now and had no issues using broadcast (tested) and looks like no issues with transferOwnership (no warnings/erros, but haven't tested). Hopefully they just did an update, otherwise, not sure what the error was previously. Thank you for giving suggestion.