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

How to get the Parent of Mouse.Target?

Asked by 4 years ago
Edited 4 years ago

I'm trying to find the parent of the mouse.Target but I can't find a way to do it

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local mTar = mouse.Target


mouse.Button1Down:Connect(function()
    print("hi1")
    if mTar.Name == "Hitbox" and player.UserId == mTar.Parent.Parent.PlantOwner.Value then
        print("hello")
    end
end)

Any help would be appreciated!

1 answer

Log in to vote
0
Answered by 4 years ago

Never mind... found the solution. My variables were messing it up. I had to write mouse.Target instead

0
Yes, that was your issue. Upon declaring mTar, it took note of what the mouse was targeting at that very time, it wouldn't renew unless you asked to get the target on clicking. Ziffixture 6913 — 4y
Ad

Answer this question