ImageId is not a valid member of Tool

The title says it . I use value to store image id for my hotbar but it give an error ImageId is not valid member of tool.This is the line that error

slotClone.GunIcon.Image =  "rbxassetid://"..tool.ImageId.Value

any help is appreciated :grinning:

1 Like

Can I see your explorer list to see what you have inside? Most likely it could be a misspelling.

Tools don’t have an imageid. The property you might be looking for is BackpackItem.TextureId
I know it says BackpackItem, for some reason the API doesn’t show this property in Tool but it does appear in Properties.
image

1 Like

SORRY LATE:
this is the image
Screenshot (14)

inside imageid value:
Screenshot (16)

not for tool but for image button

May I see the script? (sorry for asking for way too many things but thats how I can determine whats wrong)

here:

game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)


local plr = game.Players.LocalPlayer
local char = plr.Character

local backpack = plr:WaitForChild("Backpack")


local tools = backpack:GetChildren()


local slotMax = 8


local hotbar = script.Parent


local numberToWord = 
	{
		[1] = "One",
		[2] = "Two",
		[3] = "Three",
		[4] = "Four",
		[5] = "Five",
		[6] = "Six",
		[7] = "Seven",
		[8] = "Eight",
		[9] = "Nine"
	}


local function updateHotbar()


	for i, child in pairs(hotbar:GetChildren()) do

		if child.Name == "Slot" then child:Destroy() end
	end


	for i, tool in pairs(tools) do


		if i > slotMax then return end


		local slotClone = script:WaitForChild("Slot"):Clone()
		slotClone.HotkeyNumber.Text = i


		slotClone.GunIcon.Image =  "rbxassetid://"..tool.ImageId.Value


		slotClone.Parent = hotbar


		if tool.Parent == char then

			slotClone.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
		end


		game:GetService("UserInputService").InputBegan:Connect(function(input, processed)

			if not processed then

				if input.KeyCode == Enum.KeyCode[numberToWord[i]] then

					game.ReplicatedStorage.RemoteEvent.Tool.EquipToolRE:FireServer(tool, tool.Parent)			
				end
			end
		end)
	end
end

updateHotbar()


backpack.ChildAdded:Connect(function(child)

	if not table.find(tools, child) then
		table.insert(tools, child)
		updateHotbar()
	end
end)

backpack.ChildRemoved:Connect(function(child)

	if child.Parent ~= char then
		table.remove(tools, tools[child])
		updateHotbar()
	end
end)


char.ChildAdded:Connect(function(child)

	if child:IsA("Tool") and not table.find(tools, child) then
		table.insert(tools, child)
		updateHotbar()
	end
end)

char.ChildRemoved:Connect(function(child)

	if child.Parent ~= backpack then
		table.remove(tools, tools[child])
		updateHotbar()
	end
end)



game.ReplicatedStorage.RemoteEvent.Tool.EquipToolRE.OnClientEvent:Connect(function()


	for x, slot in pairs(hotbar:GetChildren()) do


		if slot:IsA("Frame") then

			local tool = tools[tonumber(slot.HotkeyNumber.Text)]

			if tool.Parent ~= char then

				slot.BackgroundColor3 = Color3.fromRGB(57, 57, 57)

			else
				slot.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
			end
		end
	end
end)

It depends on where you cloned this and where all of the objects are parented. Tool and slotClone could be separate.

Im sorry but I dont get wym…

Can you try doing

local imageId = tool:FindFirstChild("ImageId")
if imageId == nil then return print("No Id") end

print(imageId.Name)

Right before the error line?

If it returns No Id, for some reason the ImageId is not inside the pistol.

Edit: @Juicy_Fruit is most likely right, you should try using WaitForChild

might have to waitforchild on the contents of tools, in particular the decalid, seeing as though the function fires instantaneously when loaded

1 Like

It print the imageid… no error was found but the image not showing…

Alright, then maybe try what Juicy_Fruit suggested, and do

local imageId = tool:WaitForChild("ImageId")
slotClone.GunIcon.Image =  "rbxassetid://"..imageId.Value

Oh my…it working perfectly. So the who thing was just adding WaitForChild()… anyway thanks again guys my stress just gone :sweat_smile: :sweat_smile:

1 Like