Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this inventory gui script doesn't clone the gui "Template"?

I'm trying to make a inventory gui like booga booga but the gui won't clone it self to the gui when you collect a item and there's no error in the script.

script

game:GetService("ReplicatedStorage").ItemAmount.OnServerEvent:Connect(function(player)
	for i, item in pairs((player.Inventory:GetChildren())) do
		if (not player.PlayerGui.Inventory.InventoryFrame:FindFirstChild(item.Name)) then
			local clone = game:GetService("ServerStorage"):WaitForChild("Template")
			clone.Name = item.Name
			clone.ItemName.Text = item.Name
			clone.Count.Text = item.Value
			
			
			item:GetPropetryChangedSignal("Value"):Connect(function()
				clone.Count.Text = item.Value
			end)
				clone.Parent = player.PlayerGui.Inventory.InventoryFrame
		end
	end
end)

1 answer

You forgot to write :Clone() at the end of line 04. Try this:

game:GetService("ReplicatedStorage").ItemAmount.OnServerEvent:Connect(function(player)
    for i, item in pairs((player.Inventory:GetChildren())) do
        if (not player.PlayerGui.Inventory.InventoryFrame:FindFirstChild(item.Name)) then
            local clone = game:GetService("ServerStorage"):WaitForChild("Template"):Clone()
            clone.Name = item.Name
            clone.ItemName.Text = item.Name
            clone.Count.Text = item.Value


            item:GetPropetryChangedSignal("Value"):Connect(function()
                clone.Count.Text = item.Value
            end)
                clone.Parent = player.PlayerGui.Inventory.InventoryFrame
        end
    end
end)

2 comments

0

it doesn't work

0

Maybe it's your RemoteEvent that isn't working. Are there any errors?

This discussion is preserved as it was. New answers, comments, and votes are closed.