Attempt to index nil with textureId

Hello,
I have problems with Scripting tool image to image button . It give me an error that said

  18:25:21.421  ServerScriptService.Script:12: attempt to index nil with 'TextureId'  -  Server - Script:12

But I don’t see any problem in my scripts. Here is the script:

ame.ReplicatedStorage.UpdateItem.OnServerEvent:Connect(function(player)
	for i , item in pairs(player.Inventory:GetChildren())do
		if not player.PlayerGui:WaitForChild("ScreenGui" , 1):WaitForChild("Frame" ,2).ScrollingFrame:FindFirstChild(item.Name) then
			
			local image = game.ReplicatedStorage:FindFirstChild(item.Name)
			
			local temp = game.ServerStorage.ImageButton:Clone()
			temp.Count.Text = item.Value
			temp.nama.Text = item.Name
			temp.Parent = player:WaitForChild("PlayerGui" , 2):WaitForChild("ScreenGui" , 1).Frame.ScrollingFrame
			temp.Name = item.Name
			temp.Image = image.TextureId
			
			item:GetPropertyChangedSignal("Value"):Connect(function()
				temp.Count.Text = item.Value
			end)	
		end
	end
end)

The problem start at this line

temp.Image = image.TextureId

Any help is appriciated :smiley:

1 Like

Most likely FindFirstChild returns nil.

I suggest you print(item.Name) to see if you request some item that is non-existent.

1 Like

Yep… indeed it print nill. But why ??

1 Like

wait nvm…youre right there is tools that is not in replicatedstorage. Thanks btw

2 Likes