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

Is there any way to "whitelist" a BasePart from being the mouse's target?

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

2 answers

✓ Accepted answer

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.

4 comments

0

I tried that for the model not the part it's self. I'll try it.

0

It doesn't work.

0

oh crap. I wasn't using the object that was on the players mouse as the target filter.

0

Glad I could help :) Also, I really don't like to ask but could you upvote me please, if it's not a bother? I really want and am really close to get to the next reputation rank.

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

1 comment

0

This wouldn't work. The mouse is always hovering over the part.

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