Is it me or is Mouse.Target not working?

So for some reason Mouse.Target doesn’t work, if I try waiting for the child using the variable local player = game.Players:WaitForChild("LocalPlayer") it still doesn’t work? Anyways, here’s the script.

local Tool = script.Parent
local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player.Mouse

Tool.Activated:Connect(function()
if mouse.Target then
mouse.Target:Destroy()
end
end)

Tool.Equipped:Connect(function()
if mouse.Target then
mouse.Target.BrickColor = Color3.fromRGB(210, 0, 0)
mouse.Target.Transparency = 0.5
end
end)

Maybe this is the issue, try that:

game.Players.LocalPlayer

I already tried that, doesn’t work.

Also, it is:

local mouse = player:GetMouse()

It still doesnt work if I try that, I tried changing it to game.Players.LocalPlayer and with the player:GetMouse(), still doesn’t work, I tried it with waitforchild and says possible infinite yield and doesn’t delete anything when i click (activated), neither when i hover over an object (equipped).

I’m not with my pc right now, so I can’t test it, but let’s try the basics:

-- LocalScript
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()
   print(mouse.Target and mouse.Target:GetFullName())
end)
1 Like

I’m trying to put it in a tool…

Wait I don’t have it in a localscript, is that the issue?

2 Likes

Oh, so that’s really the problem.

game.Players.LocalPlayer can only be accessed by LocalScripts.

Quick question, how do I make it so if I let go of hovering over the brick, the color goes back to regular?

Use Mouse.Button1Up. Also use Mouse.Move to check if the target is the same.

BrickColor should be changed to Color here:

Thanks, but I already did that. (i noticed it)

1 Like