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
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
Also @peepo12343, try using ClassName, probably wonât make a difference but worth a shot.
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â.
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.