Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
hub64 0
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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.

0
Ok,I'll Try it hub64 0 — 7y
0
Nothing wrong with the code. I would assume there's something wrong with the IDs. OldPalHappy 1477 — 7y
Ad
Log in to vote
0
Answered by
hub64 0
7 years ago

Hard To say. It Didn't Work :(

Answer this question