Invalid argument 3, string expected got nil when I try to call i:Destroy() on a Frame

I want to make a function that will destroy all of the ItemFrames in my ItemFrameHolder, but I’m getting the error “invalid argument #3 (string expected, got nil)” when I try to call i:Destroy(). Here is my code:

function destroyAllItemFrames()
	for v,i in pairs(itemFrameHolder:GetChildren()) do
		if i:IsA("Frame") then
			i:Destroy()
		end
	end
end

This has never happened to me before, does anyone know why this is happening? If so, please respond.

Thanks,
p0s_0/OldBo5.

You didn’t provide enough code for us to debug it.

Looking at the error, your calling a function or a method, with 3 arguments, that takes i 's name as the 3rd value. Check what line the error is on.

It’s on the

i:Destroy() 

line. You can make your own variable with itemFrameHolder, make sure it’s a Frame though and add a couple just to make sure it’ll destroy.

are you sure you’re looking in the right script? the error shouldn’t be coming from that line. we also need more information than just this function

2 Likes

I wasn’t looking at the right script. I just realized, sorry about that.

1 Like