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

Any way to detect where the mouse is?

Asked by
lomo0987 250 Moderation Voter
10 years ago

I am looking to create a 'tooltip' for my game, and i want to put it next to the mouse when they scroll over it.

All I need is to know if there is a function for it if so, could you provide the link to the wiki?

2 answers

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
local mouse = game.Players.LocalPlayer:GetMouse()
local tool_tip = Instance.new("TextLabel")

mouse.Move:connect(function()
    if mouse.Target then 
        local target = mouse.Target
        tool_tip.Parent = script.Parent
        tool_tip.Text = target.Name
        tool_tip.Size = UDim2.new(0,tool_tip.TextBounds.X,0,tool_tip.TextBounds.Y)
        tool_tip.Position = UDim2.new(0,mouse.X-tool_tip.TextBounds.X,0,mouse.Y-tool_tip.TextBounds.Y)
    else
        tool_tip.Parent = nil
    end
end)
0
This is quite interesting. But I'm going to need to edit it a bit :/ lomo0987 250 — 10y
Ad
Log in to vote
-1
Answered by
HexC3D 830 Moderation Voter
10 years ago

Let's say you have a tool and put in starter gear You can use Function make sure the script inside the tool is a local script



game.Players.PlayerAdded:connect(function(plr) local mouse = plr:GetMouse() for i = 1, 1 do print(mouse.X, mouse.Y) wait(3) end end)

Idk if it works

0
I'm asking if there is a way to detect the mouse without a tool. lomo0987 250 — 10y
0
Oh mk HexC3D 830 — 10y
0
Tada? HexC3D 830 — 10y

Answer this question