Why is the Image not getting destroyed sometimes?

  1. What do you want to achieve and what’s the issue? Well I am doing a Menu for my game and I found out a error on the game really annoying. The problem is that everytime the mouse hover to the text button, it gets to replicated storage where there is a folder called “Icons” with a ImageLabel inside of it and then I clone this Icon to put near the TextButton so it is like “Hovered”.

The point is, I made a function everytime the player’s mouse leave the TextButton, the clone is destroyed. But I am expericianting an error that doesn’t delete it and the image just stay there, as if never happened. But other images continue to Clone and get to there, just the one that was not destroyed though. Sometimes this problem occurs, sometime not… I want to make it so the image is deleted sucessfuly.

  1. What solutions have you tried so far? Well I have looked to the DevForum but I didn’t find anything, just: “Destroy() do not working” or something like that… I already put “WaitForChild()” to try to delete when it gets to there, but nothing works.

The Script

Remember the Error can or not happens.


As you can see, I am out of the textbox and it is literally not destroyed/still there.

It seems to happen just when the “While v.MaxVisibleGraphemes == 0 then” is happening, but yet I don’t know how to fix.

Any help is appreciated, thank you in advance.

1 Like

Seems like you are doing unnecessary cloning; just create one clone and toggle its visibility and move its position to the mouse cursor when the user clicks

2 Likes

You mean making a singular image, make it transparency 1 and just change its position and transparency when necessary? Thank you though! I am new to scripting, and I have a bunch of problems every day. I am trying hard to be a professional!

1 Like

Yep

2 Likes

Also, if you are using WaitForChild use it with a timeout parameter, preferably smth like 2 or 3 seconds

2 Likes

Is there someway to make the While loop on each function turns global to everyone? I already tried, but failed.

1 Like

It seems Like it got fixed, thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.