Can you provide more context? Such as where you define “InventoryGUI”?
What does this mean then? Was that supposed to happen.
It was for debugging purposes, it means that the current ImageB wasn’t an ImageButton, which si correct as it was a UIGridLayout for you
It was suppose to print either true
or false
and the item’s ClassName
local item = "Part"
print((item == "BasePart"), item)
-- prints "false, Part"
The difference is; ipairs
doesn’t iterate through indexes which aren’t ints and not following the previous int.
Ex.
Im lost honestly. I have tried what has been suggested. Any other ideas? I think it may have something to do with folders.
You… you are right!
sorry for being dumb lol
Uh what should I do here guys? I dont think I can do this a lone.
Why you need to use GetDescendants()
? From where is your .Changed
event?
Try doing this in your code:
if Object:IsA("ImageButton") then
print(Object.Name, "is a ImageButton!")
else
print(Object.Name, "isn't a ImageButton.")
end
Please try this, so I can investigate further:
for _,ImageB in pairs(InventoryGUI.ItemOrder:GetDescendants()) do
plerr.DropItem.Changed:Connect(function()
print(ImageB)
end)
end
Okay I will then. One moment I will be back.
Is it not finding our frame? That is strange. Maybe the frame is not an item yet because I am adding the frame at the same time as I am changing plerr.DropItem to true?
I dont think that is it though.
Yeah, I do think that’s the issue.
That could be what’s causing it as you’re not giving the game time to find it, maybe try adding a wait() between adding the frame and setting it to true
Using wait()
is bad practice!
Why?
Yes I know that, but using it in this case will help determine if there’s not enough time between both actions that it doesn’t show up during the loop. @OP can decide if he wants to find a better way to do it or not if it in the end was due to not enough time between both actions
for _,ImageB in pairs(InventoryGUI.ItemOrder:GetDescendants()) do
InventoryGUI.ItemOrder.ChildAdded:Connect(function()
print("DEF")
if ImageB:IsA("ImageButton") then
print("OVSE")
end
end)
end
It print “DEF” but wont print “OVSE”. Why do you think this is? The Image button is added before.
It’s probably the way you did it maybe try this
InventoryGUI.ItemOrder.ChildAdded:Connect(function()
print("DEF")
for _,ImageB in pairs(InventoryGUI.ItemOrder:GetDescendants()) do
if ImageB:ISA("ImageButton") then
print("OVSE")
end
end
end)
Edit: Forgot a bracket
You are very right. Okay thanks Ill see if the rest works out.