Why does this exist on the client but nil on the server?

For my placement system, the block that’s being placed exists on the client, but it prints nil on the server.
image
image
image

Where do you create the block? On the server or the client?

If you create an Instance on the client via a localscript, it will not exist on the server.

1 Like

It’s cloned from ReplicatedStorage, so is it the same reason?

Clone it from ServerStorage with a server script

--
CloneEvent.OnServerInvoke = function(Player)
	local ClonePart = Part:Clone()
	return ClonePart
end
--
local ClonedPart = CloneEvent:InvokeServer()

RES.Remotes.PlaceBlock:FireServer(ClonedPart, block, target)

Now everything works fine, until I add a :Clone(), which I need or this happens:

You didn’t set the parent though

I changed the code a bit.

characters

Don’t send instances to the server through remote events. If you are sending something such as mouse.Target that is ok but avoid sending instances you created or cloned on the client. If you want block to be visible to all other players, create it on the server. If not, send any necessary information about it to the server.

I’m past that, the part gets set on the server and it’s fine now, except for the error a few posts above.

Are you cloning it on the server? Make sure to parent the new clone after you set any necessary values.

If I clone it on the server, it’s nil on the client.

You could use a remote function or just fire the remote event back with the new instance after you parent it.

It’s already in a remote function.
image

Try setting the parent somewhere the client can access before you return it.

1 Like

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