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

How do you make it so when the user's mouse is idle, it does something when it is...?

Asked by 7 years ago

How do you make it so when the user's mouse is idle, it does something when it is touching the text label? Thanks!

player.PlayerGui.ScreenGui.TextLabel.MouseEnter:connect(function()
    if player:GetMouse().Idle then

    end
end)

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

You could connect and disconnect the idle event while the mouse is inside the text label but this may not be the best solution, but a solution nevertheless.

Example:-

local mouse = game.Players.LocalPlayer:GetMouse()
local con = nil

local textLabel = player.PlayerGui.ScreenGui.TextLabel

local function idle()
    print('idle')
end

textLabel.MouseEnter:Connect(function()
    con = mouse.Idle:Connect(idle) -- connect the idle event
end)

textLabel.MouseLeave:Connect(function()
    con:Disconnect() -- disconnects the idle event
end)

I hope this helps, please comment if you do not understand how / why this code works.

Ad

Answer this question