RemoteFunction returning nil?

So im trying to pass the “Boomerang” back to to client but the client states that its returning nil

Heres some code:
SERVER SCRIPT:

CLIENT SCRIPT:
Screenshot 2023-07-16 155618

1 Like

This happens if the instance exists on the sender’s side (server) but not the receiver. I don’t know why it would be happening in this case though. Try parenting it to something else?

2 Likes

Okay tried parenting it to workspace and Spawnlocation (in workspace) none work

1 Like

You can’t send instances through remotes.

What you can do is assign a unique id to the instance, and pass that id as an integer or string.

Then on the client you search for an instance with that id.

You can; the Instance in question just needs to exist on both the client and server.


@daN_1elx What does your new code look like?

They are serialized to be the instance’s name. You need to have a unique name (id).

You returned the boomerang back through the server script.

What shouldve been done is that When sending the boomerang back to the client
you use :InvokeClient(plr,Boomerang)

And a function to fetch the boomerang
such as

BoomerangEvent.OnCliemtInvoke(Boomerang)
--boomerangcode
end

Those are referring to table indices:

I pass Instances through Remotes all the time

1 Like

I changed a few things on the server but still gives the same error (Client hasnt changed)

Ah you’re right. I never do that but it’s personal preference I guess… Sorry for the misinformation, and thanks for teaching me something new :blush:.

You’re parenting to the character, so the boomerang can get destroyed when the character respawns.

In the game the character cant die because respawn disabled and borders around map. Also there are no killable stuff (If you know what I mean)

Do you see the boomerang instance on the client in the studio explorer?

Yeah it appears on the character and I even see it in the workspace but the client isnt able to retrieve it

These are the prints being outputted
Screenshot 2023-07-16 160608

It’s possible that it is only visible to the client after some time passed. Especially if you use Streaming enabled.

1 Like

Ahh your right when I disabled content streaming it worked but is there any way to resolve this?

Usually for streaming you use either collection service, or waitforchild.

Can you tell us some more about what you want to do on the client?

Well im just trying to keep the camera on the boomerang when it is thrown using runservice

Oh wait I managed to fix it

I added a task.wait(0.25) and it worked thanks to @apenzijncoolenleuk1 for the Content Streaming reminder!

Collection service could be used to detect whenever a boomerang is streamed in to the player.

But I imagine you only want the camera to lock onto that player’s boomerang, and not to other boomerangs.

I would use an attribute on the boomerang ‘PlayerName’.

When a boomerang with

localPlayer.Name=boomerang:GetAttribute("Player name")

Is streamed in, force the camera to that boomerang. Make sure a player can only spawn one boomerang at a time.

1 Like