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

How do I fix my Mouseover GUI behaving in an odd manner?

Asked by 2 years ago

Hey there.

I've tried creating a Mouseover GUI. This means, that as soon as I hover my mouse over a part that has a certain string value in it, a text appears above the mouse cursor.

However the position is not really where its intended to be. The other stuff works perfectly fine, but the text is really offset. Here's the code:

local localPlayer = game.Players.LocalPlayer
local lPlayerMouse = localPlayer:GetMouse()
local moLabel = script.Parent.MouseoverText
local config = game:GetService("ReplicatedStorage"):FindFirstChild("Config_MouseInteractions")

function mPosUpdate()
    local mTarget = lPlayerMouse.Target
    if mTarget and mTarget:FindFirstChild("setMouseoverTXT") then
        moLabel.Position = UDim2.new(0, lPlayerMouse.X, 0, lPlayerMouse.X)
        moLabel.Text = mTarget.setMouseoverTXT.Value
       -- moLabel.Visible = true
    else
       -- moLabel.Visible = true
    end
end

lPlayerMouse.Move:Connect(mPosUpdate)
mPosUpdate()

Here's a Gyazo of it in action.

Thank you in advance, Ben.

0
Solved it myself, it was just me being silly and having the ui element sizing and position messed up. BenClownish 0 — 2y

Answer this question