The Game cant find the Object inside a folder

local GemsButtons_Folder = game:GetService("ServerStorage"):FindFirstChild("GemsButtons_Folder")

Loot_to_Inventory_Event.OnServerEvent:Connect(function(plr, textbutton)
	print(textbutton)
	local TextButton = GemsButtons_Folder:FindFirstChild(textbutton)
	print(TextButton)
	--if TextButton then
	TextButton:Clone().Parent = plr:FindFirstChild("Inventory")
	--end
end)

Explorer
image

What it prints

Thank you

1 Like

Thats the error

attempt to index nil with 'Clone'
1 Like
local GemsButtons_Folder = game:GetService("ServerStorage"):FindFirstChild("GemsButtons_Folder")
Loot_to_Inventory_Event.OnServerEvent:Connect(function(plr, textbutton)
	print(textbutton)
	local GetChildren = GemsButtons_Folder:GetChildren()
	for i = 1, #GetChildren do
		if GetChildren[i]:IsA("TextButton") then
			print(GetChildren[i])
			--if TextButton then
			GetChildren[i]:Clone().Parent = plr:FindFirstChild("Inventory")
			--end
		end
	end
end)

its because you aren’t specifying what the script should print. For example:
print(TextButton.Name)

But you aren’t telling what the script should print

3 Likes

I dont understand what you mean. I try to print just the Instance (it will print the adress of the object inside the memory)

1 Like

I dont understand why you gave me this script. This script will just shove all the children of the gembuttons folder (all the textbuttons) inside the players inventory. I need only the textbutton with the name that got sent by the client.

1 Like

Can I see the client script which uses FireServer.

1 Like
		--Moves the Gem to Inventory
		textbutton.MouseButton1Down:Connect(function()
			Loot_to_Inventory_Event:FireServer(textbutton.Name)
			textbutton.Parent = PlayerGui:WaitForChild("InventoryScreenGui"):WaitForChild("InventoryFrame").ScrollingFrame
		end)
1 Like

try print GemsButtons_Folder

if it doesn’t print nil replace line 68 with:

local TextButton = GemsButtons_Folder:WaitForChild(textbutton)
1 Like

oh I figured out the issue you are moving the textbutton when the remote event is fired.

Do this line in the remote event:

textbutton.Parent = PlayerGui:WaitForChild("InventoryScreenGui"):WaitForChild("InventoryFrame").ScrollingFrame
1 Like

Isnt what you sent me the same thing I have?
Like the same line of code

1 Like

No I added waitforchild()

char limit

1 Like
textbutton.Parent = PlayerGui:WaitForChild("InventoryScreenGui"):WaitForChild("InventoryFrame").ScrollingFrame

I added this piece of code, still doesnt work

1 Like

If I put the line of code in the server, it infinite yields

local TextButton = GemsButtons_Folder:WaitForChild(textbutton)
1 Like

In the remote event you are doing this:

textbutton.Parent = PlayerGui:WaitForChild("InventoryScreenGui"):WaitForChild("InventoryFrame").ScrollingFrame

Remove this line and put it in the remote event at the end

1 Like

that means GemsButtons_Folder is nil

1 Like
		--Moves the Gem to Inventory
		textbutton.MouseButton1Down:Connect(function()
			Loot_to_Inventory_Event:FireServer(textbutton.Name)
			textbutton.Parent = PlayerGui:WaitForChild("InventoryScreenGui"):WaitForChild("InventoryFrame").ScrollingFrame
		end)

after what end? this is the whole block of code

1 Like

yea the GemsButtons_Folder isnt found for some reason

1 Like

Can you show the entire remote event script?

1 Like

Explorer
image

Variable

local GemsButtons_Folder = game:GetService("ServerStorage"):FindFirstChild("GemsButtons_Folder")
1 Like