Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm Haveing Trouble Doing if Mouse leaves Change Image to the way it is?

Here's My code

local ImageButton = script.Parent

ImageButton.MouseEnter:connect(function() 
ImageButton.Image = "601721143" 
local ImageButton = script.Parent
end)
local ImageButton = script.Parent

ImageButton.MouseLeave:connect(function() --Sets up the function for when the mouse hovers over said GuiObject
ImageButton.Image = "619984177" 
local ImageButton = script.Parent
end)

If my mouse leaves It wont chnage back.

2 answers

Try this:

local ImageButton = script.Parent

ImageButton.MouseEnter:Connect(function() 
	ImageButton.Image = "601721143" 
	ImageButton.MouseLeave:Wait()
	ImageButton.Image = "619984177" 
end)

You defined ImageButton so many times and you don't have to. Just define it once. Also, Instead of using two functions I used one. This is shorter and a bit cleaning in my opinion.

Let me know if this works for you.

2 comments

0

Ok,I'll Try it

0

Nothing wrong with the code. I would assume there's something wrong with the IDs.

This discussion is preserved as it was. New answers, comments, and votes are closed.