local function GetTouchingParts(part)
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
if not part:IsDescendantOf(part.Parent) and part.Name ~= "Grid" then
return results
end
end
clone.PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()
local results = GetTouchingParts(clone.Collision) -- Collision is the hit box of the object
if results then
print(results)
print("touching")
end
end)
Having difficulty with making hit box detection. Goal:
If the objects hit box touches another object it should print "hit box is colliding with another object"
Any code snippets would be great thanks!
function GetTouchingParts(hitbox)
local connection = part.Touched:Connect(function() end
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
for _, v in pairs(GetTouchingParts(clone.Collision)) do
if not v:IsDescendantOf(part) then -- Ensuring it doesn't trigger when registering with itself.
print(v:GetFullName())
end
end
Its working, but there are a few issues.
And sometimes I could place a chair inside a chair. Current Code:
local function GetTouchingParts(hitbox)
local connection = hitbox.Touched:Connect(function() end)
local results = hitbox:GetTouchingParts()
connection:Disconnect()
return results
end
clone.PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()
for _, v in pairs(GetTouchingParts(clone.Collision)) do
if not v:IsDescendantOf(clone) or v.Name == "Grid" then -- Ensuring it doesn't trigger when registering with itself.
box.Color3 = Color3.new(0.996078, 0.133333, 0.133333)
touching = true
else
box.Color3 = Color3.new(0, 0.615686, 0)
touching = false
end
end
end)