Why is my remote event receiving nil as value (Bug?)

Im only trying to send my pet model to the server, so it can add to player’s inventory

Im sending right here a value to my remote event in the server side:


If i debug that and try to find Pet.Name it actually exists and shows the pet that you got.
image
Everything is ok here, it also prints the Pet.Name if i try, but the problem is happening in the server side.
image

If i even try to Print Pet.Name here it says i can’t print a nil value, when i also use debug Pet means nil to the server

What’s Wrong?

4 Likes

Sending items from the client to the server through a remote event does not replicate them across the client/server boundary (that would cause a huuuge security risk).

Replicating this will be a very big pain in the ass since “Pet” is a model and you’d have to pass through way to many variables in order to recreate it, HOWEVER if this model is stored on the server somewhere, you can pass along the Pet’s name (Pet.Name) as opposed to passing along the pet model itself: value types that aren’t Instances can be passed through RemoteEvents and be replicated to the server so you are free to include strings, integers, etc in your parameters.

3 Likes

I’m pretty sure you can send userdata through remote events. It’s even said in the documentation.

An interesting thing to note which could be the possible issue is this,

So if this pet is created on the client, then that explains why it is passing in nil.

1 Like

Updated my reply - forgot to include part of the sentence there! :sweat_smile:

Userdatas can be passed through to the server, but Instances (which are userdatas) will not be replicated from client to the server when passed through a remote event.