Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Any way to detect where the mouse is?

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

✓ Accepted answer
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)

1 comment

0

This is quite interesting. But I'm going to need to edit it a bit :/

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

3 comments

0

I'm asking if there is a way to detect the mouse without a tool.

0

Oh mk

0

Tada?

This discussion is preserved as it was. New answers, comments, and votes are closed.