Why can't it find the parent?

I have a remote event (server to client).
I clone a textbutton inside on the server side and send the clone to the client
It says that it cant find the textbutton that has been cloned on the server side

SERVER

local GemsButtons_Folder = game:GetService("ServerStorage"):WaitForChild("GemsButtons_Folder")
			local ClonedGemButton = GemsButtons_Folder:FindFirstChild(gem.Name):Clone()
			Inventory_Event:FireClient(plr, ClonedGemButton:Clone())
			ClonedGemButton.Parent = Inventory

CLIENT

Inventory_Event.OnClientEvent:Connect(function(clonedgembutton)
	print(clonedgembutton) 
	clonedgembutton.Parent = InventoryScrollingFrame
end)

the print statement in client prints nil
I know that I can put the gemfolder in the replicatedstorage to fix this issue, but I dont want to move the folder. Is there a way to fix it?

1 Like

The error in the client script says

attempt to index nil with 'Parent'

Why are you parenting the object twice?

Choose one or the other.

One is going to the client, the other is going to the server side

If you already did it in the server, why do it again in the client? Are they parented to different places?

I assume it’s because you’re using fireclient with a random clone that might be in nil, how about you try moving it to the player’s playergui before firing it on their client, or just fire the client with the name of the button?

local ClientCopy = ClonedGemButton:Clone()
ClientCopy.Parent = plr:WaitForChild("PlayerGui")
Inventory_Event:FireClient(plr, ClientCopy)
1 Like

Yes, exactly. One is parented to a scrollingframe, the other is parented to the players inventory

I cannot fire with the name of button, because I wont be able to get it since its in replicated storage.

replicatedstorage shows on both the client and the server, but I recall you saying your buttons were in serverstorage, so I get what you mean
I guess try the code I posted and hmu if it works

You can access both server and client on replicated storage

Try what @uwuCulturist suggested.

I know that, but I dont want to move it into replicated storage

Try this:

local GemsButtons_Folder = game:GetService("ServerStorage"):WaitForChild("GemsButtons_Folder")
local ClonedGemButton = GemsButtons_Folder:FindFirstChild(gem.Name):Clone()

local clientGemButton = ClonedGemButton:Clone()
clientGemButton.Parent = game:GetService("ReplicatedStorage")

Inventory_Event:FireClient(plr, clientGemButton)
ClonedGemButton.Parent = Inventory