Cloned Part appears as nil in Local Script

I’m trying to clone a part in a server script in ServerScriptService and then send it to a local script with a remote event. This way, I can make it visible on the client side, so only a specific player can see it.

My problem is that the local script prints the Cloned Part as nil and won’t change its transparency.

Server Script:

function CloneBrick(player)
	if db[player]  == true then
		db[player] = false

		local NewBrick = game.ReplicatedStorage.Target:Clone()
		
		NewBrick.Parent = game.Workspace

		print(NewBrick)

		game.ReplicatedStorage.HideEvent:FireClient(player, NewBrick)
end
end

Local Script:

game.ReplicatedStorage.HideEvent.OnClientEvent:Connect(function(part)

	print(part)
	part.Transparency = 0
end)

Can you show the explorer with the cloned part in workspace.

The part passed will only not be nil when these conditions are met:

  1. The part exists on the client
  2. The part exists the server

This means that one of the two conditions aren’t met. Either you have StreamingEnabled turned on for workspace and are really far away from the part (disable StreamingEnabled and see if the problem goes away). Or there is ping difference where the remote event reaches the player before the part replication does, so put a wait and see if it’s fixed.

1 Like

Might sound silly, but you might have streamingEnabled on and if you do, you have to use WaitForChild on the part on the client because it might not have streamed in yet

1 Like

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