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

How can I make a function when the mouse is touching a GUI?

Lets say, There is a Frame in the Gui. When the Mouse touches that Frame, a different script occurs.

For now, If the mouse touches the Frame, it changes color

How can I do this?

Thanks for everyone who tried and attempted to solve this problem. Much Appreciated.

1 comment

1

You could use RemoteEvents or BindableEvents.

2 answers

✓ Accepted answer

The best way to do this is to use: MouseEnter and MouseLeave events

So you gotta do this (this is an anonymous function) also, insert the following script inside the frame

local GuiFrame = script.Parent

GuiFrame.MouseEnter:connect(function()
    GuiFrame.BackgroundColor3 = Color3.new(0,0,0) --Change this with the numbers of the color.
end)

GuiFrame.MouseLeave:connect(function()
    GuiFrame.BackgroundColor3 = Color3.new(0,0,0) --change to color of when mouse is NOT over it.
end)

Hope it helps!

MouseEnter

Connecting to the MouseEnter event will allow you to connect a function to when the mouse is touching a GUI. You can combine this with MouseLeave to get when the mouse stops touching.

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