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

Trying to get a textlabel to be on players mouse?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

When I move the mouse around I want the gui to follow it.

plr = game.Players.LocalPlayer
mouse = plr:GetMouse()

Gui = script.Parent.Text

Gui.Position = UDim2.new(mouse)
1
This shows little attempt. I'm not 100% sure, but you can't make a GUI Element's name "Text", as it may interfere with the "Text" property. I know you're completely capable of looking on the wiki and finding the correct event, considering you have 134 reputation. Shawnyg 4330 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

First problem:

:GetMouse does not return a position value. To fix this, do the following:

local pos = mouse.Position
Gui.Position = pos

Second problem:

This will only cover the mouse once, so it will not update itself, so:

while wait() do
    local pos = mouse.Position
    Gui.Position = pos
end

Tips:

  • Shawnyg's comment was wrong, it does not interfere, and will only interfere when you are searching for a child of an object with a Text property, when the child you are searching for is called Text. If you encounter this problem, consider renaming the child text, as the searches are case sensitive.

  • Always make sure something that needs to be updated is actually updating, see the second problem.

Hope I helped :)

~TDP

0
The Mouse object does not have a Position property. XAXA 1569 — 8y
0
I meant .X and .Y lol TheDeadlyPanther 2460 — 8y
Ad

Answer this question