Need to assign an image depending on resources

local ResourceIcons = require(game.ReplicatedStorage:WaitForChild("images"))

local player = game.Players.LocalPlayer
local resourcePanel = player:WaitForChild("PlayerGui"):WaitForChild("resources"):WaitForChild("panel")
local template = resourcePanel:WaitForChild("ResourceTemplate")
local resourceFolder = player:WaitForChild("resources")

local function connectIntValue(intValue)
	print("Watching", intValue.Name)
	intValue:GetPropertyChangedSignal("Value"):Connect(function()
		local resourceName = intValue.Name
		local amount = intValue.Value

		local guiItem = resourcePanel:FindFirstChild(resourceName)
		if guiItem then
			guiItem.TextLabel.Text = tostring(amount)
		else
			local newItem = template:Clone()
			newItem.Name = resourceName
			newItem.TextLabel.Text = tostring(amount)
			newItem.Visible = true
			newItem.Parent = resourcePanel
		end
	end)
end
for _, intValue in pairs(resourceFolder:GetChildren()) do
	if intValue:IsA("IntValue") then
		connectIntValue(intValue)
	end
end

resourceFolder.ChildAdded:Connect(function(child)
	if child:IsA("IntValue") then
		connectIntValue(child)
	end
end)

i made a module script containing each resources respective image, but i cant figure out how to make this script assign each image the one it needs to have. like, if i collect a plank, make the new image in the panel and give it the plank image, and then if i collect a stone give it a stone image


if you need any other information abt smth ill give it

I recommend using strings as indexes in the module script:

local resoureicons = {
    ["plank"] = "your id",
    ["stone"] = "your id"
}

return resourceicons

LocalScript:

local ResourceIcons = require(game.ReplicatedStorage:WaitForChild("images"))

local player = game.Players.LocalPlayer
local resourcePanel = player:WaitForChild("PlayerGui"):WaitForChild("resources"):WaitForChild("panel")
local template = resourcePanel:WaitForChild("ResourceTemplate")
local resourceFolder = player:WaitForChild("resources")

local function connectIntValue(intValue)
	print("Watching", intValue.Name)
	intValue:GetPropertyChangedSignal("Value"):Connect(function()
		local resourceName = intValue.Name
		local amount = intValue.Value

		local guiItem = resourcePanel:FindFirstChild(resourceName)
		if guiItem then
			guiItem.TextLabel.Text = tostring(amount)
		else
			local newItem = template:Clone()
			newItem.Name = resourceName
			newItem.TextLabel.Text = tostring(amount)
			newItem.Visible = true
			newItem.Parent = resourcePanel
            newItem.Image = ResourceIcons[resourceName]
		end
	end)
end
for _, intValue in pairs(resourceFolder:GetChildren()) do
	if intValue:IsA("IntValue") then
		connectIntValue(intValue)
	end
end

resourceFolder.ChildAdded:Connect(function(child)
	if child:IsA("IntValue") then
		connectIntValue(child)
	end
end)