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

mouse move keeps flickering?

Asked by
unmiss 337 Moderation Voter
8 years ago

This is extremely stressful. The visibility/value of mouseIsIn keeps deciding to flicker between true or false yet my mouse is clearly in the frame/imagelabel. WHY?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local hint = script.Parent.Parent.Parent.Hint

function isVisible(GUI)
    if not GUI then return false end
    if GUI.Parent ~= player.PlayerGui then
        if not GUI.Visible then
            return false
        else
            return isVisible(GUI.Parent)
        end
    else
        return true
    end
end


function mouseIsIn(GUI)
    return isVisible(GUI) and (mouse.X > GUI.AbsolutePosition.X and mouse.Y > GUI.AbsolutePosition.Y
        and mouse.X < GUI.AbsolutePosition.X + GUI.AbsoluteSize.X
        and mouse.Y < GUI.AbsolutePosition.Y + GUI.AbsoluteSize.Y)
end

mouse.Move:connect(function()
    print(hint.Visible)
    if mouseIsIn(script.Parent.holder) then
        local text = hint:WaitForChild("HintText")
        text.Text = "This user is an administrator"
        hint.Size = UDim2.new(0,text.TextBounds.X,0,15)
        hint.Visible = true
        hint.Position = UDim2.new(0,mouse.X - hint.AbsoluteSize.X - 20,0,mouse.Y)
    else
        hint.Visible = false
    end
end)

Answer this question