Hello friends. I am making a placement system and I have found myself stuck at a little problem. When placing the object, I need to check the mouse's target is a panel from the base. Anyways, for this, I need to use mouse.Target. But the problem with doing this is that the mouse's target will always be the part I'm dragging. I've tried things to kind of "whitelist" the part from being detected such as making the part locked. This hasn't worked and I was wondering if anybody had a solution to my problem.
This is the code for the problem: (This is just a piece of the code. All variables are defined.)
local assets = replicatedStorage.CoreModule.Assets local clone = assets.Placeable:FindFirstChild(object.Name) local placeEvent = replicatedStorage.CoreModule.Events.BuyBuild if clone then local panel print(mouse.Target.Name) if mouse.Target and mouse.Target.Name:find("Panel") then local base = mouse.Target.Parent.Parent if base and base.Name:find("Base") then print'oh base yes' local config = base:FindFirstChild("Configuration") if config and config:FindFirstChild("Owner") then if config.Owner.Value.Name == player.Name then panel = mouse.Target else panel = "CannotPlace" end end end end
Hi. Have you tried using mouse.TargetFilter = workspace.BlockedPart
?
workspace.BlockedPart Isn't the actual object. Change that to the item you don't want to block your mouse ray.
Just create a table, with the whitelisted part as the key. When you check for the mouse target, just have an if statement that checks if the current target is a valid index in the table