You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
Im making a build system where the part goes red if it touches an object and green if it doesn’t.
Instead of going red as soon as the part touches an object I would like it to go red if it gets within a certain distance so I can allow for it to go slightly through the part. -
What is the issue?
When I bring the client structure thats to be placed inside of a part it goes red I don’t want it to go red straight away I want it to go red only if it goes so far into the part -
What solutions have you tried so far?
I tried finding all the touched parts then setting a distance the problem with this is it takes the distance from the centre of the part I need it to take the distance from the edge of the part.
function GetParts(struc)
local overlap = OverlapParams.new()
local IgnoreList = {clientStructure, workspace.Terrain}
overlap.FilterDescendantsInstances = IgnoreList
local TouchList = workspace:GetPartsInPart(struc, overlap)
if #TouchList > 0 then
for i,v in pairs(TouchList) do
warn(v)
if (v.Position - clientStructure.Position).magnitude < 4 then
return true
end
end
else
warn("NO PARTS TOUCHING!")
return false
end
end