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

Mouse.Target only returns Baseplate?

Hello, I'm having an issue of Mouse.Target only returning "Baseplate", despite me hovering the mouse over other parts. Removing the baseplate stops the code from working altogether, even when hovered over other parts. Help would be appreciated!

The script is a LocalScript inside StarterGui.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local target = mouse.Target
local textlabel = plr.PlayerGui.ScreenGui.TextLabel

mouse.Move:Connect(function()
	textlabel.Position = UDim2.new(0, ((mouse.X+15)), 0, ((mouse.Y+5)))
	if target then
		print (target.Name)
	end
end)

Edit, I've attached a gif of the situation here; imgur link. What's weird is that it should be nil when pointing at the sky.

1 answer

✓ Accepted answer

Inside your mouse.Move:connect(function(), add a 'target = mouse.Target' so when you move your mouse, it updates the selected object.

3 comments

0

I dont understand? Plus I've already defined mouse.Target

0

You defined your target but you aren't updating it's value when you move your mouse.

0

Oh! Somehow works now, I didn't think that changing the location of "local target = Mouse.Target" would make a difference. Accepting answer!

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