RemoteEvent won't bypass Server to Client

I want pass NPC’s position to Client from Workspace.

But it always says Unable to cast value to Object or if i try pass only NPC instead cframe it says it should be player object.

I want to pass the position. Can someone help?

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
	local npc = script.Parent.Parent:WaitForChild("NPC").HumanoidRootPart.CFrame
	RS.StartGame:FireClient(player)
	RS.FitChar:FireClient(npc)
end)

When using the RemoteEvent:FireClient method, the first argument needs to be a Player. This line does not do that:

RS.FitChar:FireClient(npc)

You can still pass the npc, but you have to specify which Player you want to send the event to like this:

RS.FitChar:FireClient(player, npc)

If you want to send it to all players, then you can use RemoteEvent:FireAllClients.

1 Like

You have 2 Issues In Your Code!
First: You are not Passing the Player inside of :FireClient() It Should Be :FireClient(player, npc)

Second: This is a Very Bad Practice Because if the NPC is not loaded in player Radius For Example if You Have Streaming Enabled On Its gonna be Nil on the Client.

Thank you, it worked but can you tell me why it printed position like that:

-422.252014, 0, -661.062988, 0, 0, -1, 0, 1, 0, 1, 0, 0  -  Client - LocalScript:17

Isn’t it like x,x,x? that is other numbers. i just want to get position.

1 Like

Oh… i am garbage for scripting.

This would be true if the RemoteEvent was passing the NPC Instance/model; however, it is instead passing its CFrame. Even if the NPC does not exist on the client, the client can still receive this CFrame just fine.

the script works just when player interact to E on npc

OH It looks like i didn’t read the Post well Thanks For Clearing That out!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.