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

Move left and right hover "buttons" ?

Asked by
Trewier 146
10 years ago

I have a GUI that should move a textlabel back and forth when it has a mouse hovering over it, but no matter what I try, I cannot get it to move continuously, only when the mouse actually enters the object. I was wondering if there was a way to detect if the player's mouse is inside of a gui part and run some code if it is.

1 answer

Log in to vote
1
Answered by 10 years ago

If the gui is a simple rectangle then you could just get the position of the mouse and the boundaries of the gui. Like so:

local mouse = game.Players.LocalPlayer:GetMouse();
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel;

while wait() do
    if mouse.X <= gui.Position.X + gui.Size.X and mouse.Y <= gui.Position.Y + gui.Size.Y and mouse.X >= gui.Position.X and mouse.Y >= gui.Position.Y then
        --move code
    end
end
Ad

Answer this question