IsA is not working when looking for item

nvm, i fixed it. I added a wait which allowed things to load. I think the issue was there was no time for it to load but when i added a wait it worked.

Try using

if(v.ClassName == "ImageButton") then

--do stuff


end

The class name of any workspace item is in the properties editor under ClassName (it’s read only)

You forgot to end it :smiley:
it’s supposed to be:

for i, v in pairs(Gui:WaitForChild("list"):GetDescendants()) do
    if v:IsA("ImageButton") then
	v.MouseButton2Up:Connect(function()
            print("working")
        end)
    end
end

You forgot the second end I put in.
It’s funny that no one noticed this, except for me. No worries tho, I made a lot of small mistakes and still do.

If he forgot the end the script would error, but it doesn’t. He probably forgot to paste that here. That isn’t the problem.

what happened to the whole polling is bad lecture yesterday :laughing:

Also @peepo12343, try using ClassName, probably won’t make a difference but worth a shot.

1 Like

yah lol it’s bad however there’s no event for the GUI loading since that has to be done internally by roblox. That’s why there’s an other method I mentioned. The thing with yesterday was there was an other method which used events (so polling is unnceccary)

Polling is bad. (very bad)

Basically this is a good think to follow: DO NOT USE POLLING when event based programming is there. We don’t have an event like this. but we do have an other method (Which you should 100% follow). I probably shouldn’t have showed the polling method at all.

Only use polling when you need to absolutely use it, anyways in this case we don’t need it. So yah your right polling is bad.

The thing I talked about yesterday wasn’t necessarily a lecture unlike teachers I virtually have no power. It was telling why polling is bad. wait() can sometimes wait up to 3 seconds based on the task scheduler que.

Are you sure your objects you are looking for are actually ImageButtons?

EDIT:

You were missing an ‘end’.

1 Like

I was about to reply saying the exact same thing, given how many replies this thread has.

If the script works now, please make one of the comments a solution.
Thanks. :smiley:

1 Like