hello developers,
I just ran into a problem and would like someone to help me if you know a solution. The problem is that I am using Touched to detect if I can place the object or not, and it doesn’t work because even if the object doesn’t collide with the floor, it still hits the floor, and the touch event detect the floor, so it doesn’t let me place it.
Check collision function:
PlacementProperties.checkCollision = function(object)
for i, v in pairs(PlacementProperties.getModelParts(object)) do
local touched = v.Touched:Connect(function() end)
local collidingObject = v:GetTouchingParts() -- Gets all individual touching parts including children touching each other
if collidingObject ~= nil then
for i, v in pairs(collidingObject) do
if (not v:IsDescendantOf(object)) then
return false -- colliding
end
end
end
touched:Disconnect()
end
return true
end
Demonstration:
This is a clip of a table that I lift up a bit so that it doesn’t hit the floor and I can place it: https://gyazo.com/548c6addc92c513fd3549faf3aeda448
This a clip of a wall that isn’t lifted up like the table and I can’t place: https://gyazo.com/b156972c8305c84e4e41f24b3cf50da7
SORRY FOR THE BACKGROUND NOISES IN THE CLIPS
Any suggestion? Is there anything else that can replace the touch event, like a collision event?