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

Error 'Image' (string expected, got nil) How to fix?

I do get the error: 22:07:30.264 - Players.rangblade.PlayerGui.MainGui.LocalScript:248: bad argument #3 to 'Image' (string expected, got nil)

That happend on this line: i.ImageLabel.Image = iteminfo.image

The funtion connected this line: drawGUI(armourTextButtons)

Any one has any idea how to fix this?

And a Happy New Year!

2 answers

i.ImageLabel.Image = iteminfo.Image --uppercase i

4 comments

0

many thanks. Really stupid that I didn't see that.

0

But the same error keeps appearing and does not show up any of the images.

0

you'll have to show more code then

0

So thats no issue

Thats the whole code block. Errors on Line 248 but also points to 270, 125

spawn(function()
	--Spawn male or female clothing chosen on start
	local iteminfo = require(armourFrame:WaitForChild("Frame"):WaitForChild("Legs"):WaitForChild("ItemInfo"))
	local info = require(findItem("Underwear"))
	iteminfo.TransferData(info.GetData())
(--Line125 --)	armourEquip(iteminfo.GetData())
	drawGUI(armourTextButtons)
end)

--// Functions

function returnVector(position, pos) 
	-- Return a fixed position
	return Vector3.new(position.X,pos,position.Z)
end

function findItem(name)
	--Find Item in _assets
	for _, i in pairs(_assets:GetChildren()) do
		if i.Name == name then
			return i:WaitForChild("ItemInfo", 1)
		end
	end
end

function checkAssetsList(model)
	-- Check n returns info
	for _, i in pairs(tooltip) do
		for n, s in pairs(i.names) do
			if s == model.Name then
				return {true, i.names[n], i.tooltip, i.equipedItem, i.category}
			end
		end
	end
	return {false, "", "", ""}
end

function checkWhiteList(iteminfo) 
	-- [iteminfo]module]
	for _, i in pairs(iteminfo.whiteList) do
		if i == iteminfo.name then
			return true
		end
	end
	return false
end

function checkWater(customRegion)
	-- Check custom region if cell is water
	local region = customRegion
	region = region:ExpandToGrid(4) --ExpandToGrid doesnt exist in output
	local material, occupancy = game.Workspace.Terrain:ReadVoxels(region, 4) --and here argument 1 is nil
	local size = material.Size
	for x = 1, size.X do
		for y = 1, size.Y do
			for z = 1, size.Z do
				if material[x][y][z] == Enum.Material.Water then
					return true
				end
			end
		end
	end
	return false
end

function CreateRegion3FromLocAndSize(Position, Size)
	local SizeOffset = Size/2
	local Point1 = Position - SizeOffset
	local Point2 = Position + SizeOffset
	return Region3.new(Point1, Point2)
end

function isFull(item)
	--Variables
	local slots = 0
	--Check if inventory is not full
	for _, i in pairs(inventoryTextButtons) do
		if i:IsA("TextButton") then
			local iteminfo = require(i:WaitForChild("ItemInfo")).GetData()
			if iteminfo.id == item.id and iteminfo.stackAble and iteminfo.stack < iteminfo.maxStack then
				return true
			end
			if iteminfo.id ~= 0 then
				slots = slots + 1
			end
		end
	end
	if slots >= maxSlots then
		return false
	else
		return true
	end
end

function AnimationPlaying(anim)
	 -- Repeat wait() until anim timePosition is reach to the anim length
	playing = true
	repeat wait() until anim.TimePosition >= anim.Length
	playing = false
end

function weld(name, part0, part1, c0, c1) 
	-- Create Welds
	local w = Instance.new("Weld", part0)
	w.Name = name
	w.Part0 = part0
	w.Part1 = part1
	w.C0 = c0
	w.C1 = c1
	return w
end

function effectDurability(iteminfo, count, multiplyer)
	--Effect item durability
	if iteminfo and iteminfo.durabilityActive and iteminfo.durability >= 0 then
		iteminfo.textButton["Durability"].Visible = true
		iteminfo.durability = iteminfo.durability - count
		iteminfo.textButton["Durability"].Size = UDim2.new(0,(iteminfo.durability/100)*55,0,3)
	else
		print("Destory.."..iteminfo.name)
	end
end

function drawGUI(inventory)
	--Draw Images n Stack
	for _, i in pairs(inventory) do
		if i:IsA("TextButton") then
			local iteminfo = require(i:WaitForChild("ItemInfo")).GetData()
			if iteminfo.id ~= 0 then
(-- Line 248 --)				i.ImageLabel.Image = iteminfo.Image --uppercase i
				iteminfo.textButton = i -- just update that button every time it updates gui
				if iteminfo.stackAble and i:FindFirstChild("Stack") then
					if iteminfo.stack > 1 then
						i.Stack.Text = iteminfo.stack
					else
						i.Stack.Text = ""
					end
				elseif not iteminfo.stackAble and i:FindFirstChild("Stack") then
					i.Stack.Text = ""
				end
			else
				i.ImageLabel.Image = ""
				if i:FindFirstChild("Stack") then i:FindFirstChild("Stack").Text = "" end
			end
		end
	end
end

function drawAll()
	--Draw all GUI
	drawGUI(inventoryTextButtons)
(-- Line270 --)	drawGUI(armourTextButtons)
	drawGUI({hotBarTextButtons[1].TextButton,hotBarTextButtons[2].TextButton,hotBarTextButtons[3].TextButton})
end

1 comment

0

I have putten the original error lines in there as the whole script is much bigger.

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