✓ Accepted answer
Hey YouSNICKER,
MouseLeave and MouseEntered are the only events you can connect to that will notify your script when their respective... events, occur. I would recommend cleaning things up a bit, however. If I may, I would like to suggest that you use something called a dictionary to store your image IDs. Consider the following:
local Icon = {
Filled = "rbxassetid://591367709";
Unfilled = "rbxassetid://591355902";
};
Then accessing them like so:
function fill()
script.Parent.Image = Icon.Filled
end
function unfill()
script.Parent.Image = Icon.Unfilled
end
I prefer Dictionaries over Lists by far, because a List position (i.e. Icon[2]) just doesn't have any meaning to someone who hasn't studied the code. This matters more when programs start to get really big (trust me, I would know.) Icon.Filled, however, does have more meaning and is much more memorable. As a rule, I generally avoid lists when dealing with data meant to be manually changed, so as to control the behavior of a game. Lists are a lot better when you're dealing with loads of unsorted data that you want to iterate over using a for loop, for example, but not for storing things that you need to remember.
I share this with you because it will help you a lot as you begin to work on more complex scripts; hopefully it helps you.
Have a good one, YouSNICKER, and best of luck with your project!
Yours truly,
tkcmdr
1 comment
Thanks man!