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

Mouse.Target only returns Baseplate?

Asked by
Talveka 31
4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
9mze 193
4 years ago

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

0
I dont understand? Plus I've already defined mouse.Target Talveka 31 — 4y
0
You defined your target but you aren't updating it's value when you move your mouse. 9mze 193 — 4y
0
Oh! Somehow works now, I didn't think that changing the location of "local target = Mouse.Target" would make a difference. Accepting answer! Talveka 31 — 4y
Ad

Answer this question