I know that using the Touched event works only for Physics-based or unanchored parts, but how do I detect two anchored parts colliding? I'm making a tycoon-based game, and I've managed to place an item down, but I can't seem to account for if they are colliding?

Here's the whole script:

local hitter = game.Workspace.SpawnLocation

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

-- PART INITIALISATION
local part = game.Lighting["Game Blocks"].Props["Wall Designs"].Painting
part.Parent = game.Workspace
part.Anchored = true

-- SELECTION BOX INIT
local SelectionBox = Instance.new("SelectionBox")
SelectionBox.Adornee = part
SelectionBox.Color3 = Color3.new(0, 100, 0)
SelectionBox.Parent = part

mouse.Move:connect(function()
	if not mouse.Target or mouse.Target == part then
		return
	end
	
	hitter.Touched:connect(function(brick) -- ignore
		if brick.Name == "Painting" then
			wait()
			print("Boop")
			SelectionBox.Color3 = Color3.new(255, 0, 0)
		else
			SelectionBox.Color3 = Color3.new(0, 100, 0)
		end
	end)
	
	SelectionBox.Color3 = Color3.new(0, 100, 0)
	
	part.Position = Vector3.new(mouse.Hit.p.X, 2.3, mouse.Hit.p.Z)
end)

mouse.Button1Up:connect(function()
	cloned = part:Clone()
	cloned.Parent = game.Workspace
	cloned.Name = "Test2"
	cloned.Anchored = true
	cloned.Position = Vector3.new(mouse.Hit.p.X, 2.3, mouse.Hit.p.Z)
	cloned.CanCollide = true
	cloned.Locked = true
	cloned.SelectionBox:Destroy()
	
	cloned.Rotate:Destroy()
end)

Thanks!

1 comment

0

The part that I'm trying to detect is being moved by the mouse (CFramed)