If statement not working when statement is obviously true

Yeah I took the code out of the coroutine

like this?
image

Nevermind about using indexes then. Could it be Slotted boolean not being set to false ever? If the first iteration doesn’t return anything when calling FindFirstChild(v) the if statement in question won’t be reached anymore.

If this doesn’t help, I’d advice to slowly simplify the script until you get to a code where this problem is gone. Something like ihavoc101 is suggesting.

Yeah I think its because I have too many loops nested inside of loops

		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

See that code?
Change it to:

print(slot:FindFirstChild(v))

To check if it even exists.

Its printing something called nil

image

That means there is no object inside that frame.

Alright so what part of the code would I change around then

Check if the object is actually in the item your indexing. I’m unsure of your usecase, unfortunately. So I can’t help you there.

I tried doing this and it still isnt working either

if slot:FindFirstChild(v) == nil then
	print("nothing inside")
	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
else
	print("something inside")
	break
end

That means that there is no child with the same name as the string in v specifies. Check the object your talking about and its children.

Alright so i removed the inside and just left the prints and it works but when I add the piece of code I need to add it doesnt work

if slot:FindFirstChild(v) == nil then
	print("nothing inside")
	--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
else
	print("something inside")
	break
end

I don’t know then, unfortunately, I don’t understand your use case so I cannot provide much help. You should try to ask other programmers for their experience as well.

1 Like

Alright well thanks for everything got me a bit closer to solving the problem