My guess is that objects that haven’t been parented yet are not replicated. You’re passing the client a reference to a part that, according to the client, doesn’t exist.
I might be wrong though.
Edit: Here’s a quick fix I tested out. This should replicate the part to the clients first:
game.ReplicatedStorage.RemoteFunction.OnServerInvoke=function()
local part = Instance.new("Part")
part.Parent = game.ReplicatedStorage
part.Parent = nil
return part
end
I don’t like this. I have to parent an object made on the server before I’m allowed to send it to the client. It isn’t just Instance.new, it’s also Clone.
That part isn’t parented to somewhere so it replicates, thus doesn’t exist on the client. If you send a reference of something and the receiver doesn’t know about it, it becomes nil.
The client is creating and copying objects. New objects have to be made on the server and sent to the client so they exist on the server. Changes are made on the client and signaled to the server to verify whether the client is allowed to make those changes and then make the changes on the server.