If statement not working when statement is obviously true

Im trying to check if there is something inside of a frame that has the name of something inside of a table but it skips over it when it has something in it anyway and goes to the else

Code :

for i,v in pairs(getItems) do
	if Holding and equation and not Slotted and item.Name == Logs.itemName then
		if slot:FindFirstChild(v) then
			print("Something is inside of this frame there")
		else
			print("There is nothing inside of here")
			item.Parent = slot
			item.Position = slot.Center.Position
			spawn(function()
				setSlot:FireServer(slot.Name,item.Name,"set")
			end)
			Logs.itemName = nil
			WindowsXPBubble:Play()
			Slotted = true
			Holding = false
		end
	end
end
1 Like

what is the “getItems” variable? is it an array with names or objects? if it is an array of objects you would have to put slot:FindFirstChild(v.Name) in the statement

Yeah its an array of names of items

edit : more of the script

local simpleThread = coroutine.wrap(function()
for _, slot in pairs(MAIN:GetDescendants()) do
	for number = 1,maxSlots,1 do
		if slot.Name == tostring(number) or slot.Name == "Primary" or slot.Name == "Secondary" then
			for _, item in pairs(MAIN:GetDescendants()) do
				if item:IsA("ImageLabel") and item.Name ~= "Item" then
					local itemLocation = Vector2.new(item.AbsolutePosition.X,item.AbsolutePosition.Y) + item.AbsolutePosition / 2
					local slotLocation = Vector2.new(slot.AbsolutePosition.X,slot.AbsolutePosition.Y) + slot.AbsolutePosition / 2
					local equation = (itemLocation - slotLocation).Magnitude < 95
					for i,v in pairs(getItems) do
						if Holding and equation and not Slotted and item.Name == Logs.itemName then
							if slot:FindFirstChild(v) then
								print("Something is inside of this frame there")
							else
								print("There is nothing inside of here")
								item.Parent = slot
								item.Position = slot.Center.Position
								spawn(function()
									setSlot:FireServer(slot.Name,item.Name,"set")
								end)
								Logs.itemName = nil
								WindowsXPBubble:Play()
								Slotted = true
								Holding = false
							end
						end
					end
				end
			end
		end
	end
end

Is the variable v a string?

The v is strings of items inside of the table itemList

Is it a “string”. FindFirstChild only works if the argument is a string.

Yes it is a string and if didnt work then it would error but there are no errors in the output

i think i found the problem

maybe you forgot to call the coroutine?

Thats the coroutine for everything in the script and yeah I called that

I don’t see why it won’t work then. Are you calling FindFirstChild on the wrong frame?

Nope its on every single frame I loop through them at the beginning

Are you sure getItems is not a dictionary? If you are setting the strings as index, you should work with keys instead. Try using i as argument for FindFirstChild if that’s the case.

This is what getItems is

itemList = {
	
	"Ham";
	"Pumpkin";
	"example8";
	"example7";
	"example6";
	"example5";
	"example4";
	"example3";
	"example2";
	"example1"
	
}

change to

I’m not much of a scripter, but I know elseif has something to do with doing something else if a statement is true or false depending on what you wrote for your code. If this doesn’t even relate or help, then I don’t know. Good luck!

Thanks for trying to help but sadly its still passing through the first condition and on to the else

1 Like

Try to call it from another script. Separately.

Like a bindable event type thing?

Definitely not. Just try to call it to see if it DOES exist at the time you call it.

Could you elaborate Im so lost on what you want me to call

instead of using :FindFirstChild() in the statement, make it a variable, and print it out.

Also, try to take the code out of the coroutine.