While trying to code a inventory system for my game I keep running into the same problem. When I try to send anything other than the player to the server using remote events the server receives nill or the players name but no matter what I do the whether a send a value, a variable, a instance, or even a string the server gets the players name or nill.
What does your code look like?
From Client To Service you Pass The Value
--Client Script / Local Script
Remote:FireServer(InstanceModel) -- This will pass the payer on its own since its a local script so no need to pass the player in this Remote from the Client To Server
--Server
Remote.OnServerEvent:Connect(function(Player,InstanceModel)
end) -- if you are firing from server to client you need to pass the player you are passing it to but you do not need to reference the player on the client side
Vise Versa from server to client
Serialization, my friend. You should not be sending the part directly to the server but rather its properties – be very careful with this, use proper sanity checks to ensure exploiters don’t send, for example, ridiculously sized parts to the server regardless of what you are doing with them at that point.
Attempting to send instances to the server through remote events would just be converted into a string form of their name. Maybe use that as your advantage.
ok is see where I went wrong
from the client I sent the player and the instance
Remote:FireServer(player, InstanceModel)
yea no need to pass the player from client to server
I don’t understand what you are trying to say . . .
He is trying to say that instances like parts are not replicated to the server unless created by the server. You cannot just send a part created on the client to the server, it doesn’t exist there. You need to serialize the part’s properties and then send them over
That’s not what I’m trying to say.
@OP, what I’m trying to say is, you could use that string form name and use FindFirstChild()
with it to find that specific instance.
OP has given no context as to whether or not the instance exists on the server
This is actually what I was planning to do.