see what ever parts is close to base INCLUDING SIZE like if part.Size = Vector3.new(9,20,2) if part magnitude is close to part in that size,or like if u making a kamehameha and the beam goes forward it dont only check the middle point if the part extends it gets the front to bck magnitude and runs script
Haven't been able to test it but this should theoretically work, assuming that the parts are rectangular
FYI I only answered this because I wanted to know how to do this also, and I don't think anybody would have ever answered this question because of the request site thing.
local lowestMagnitude = 10000 local partWithMagnitude = nil local part = game.Workspace.Part local function goThroughParts(v) if #v:GetChildren() ~= 0 then for i, v2 in pairs(v:GetChildren()) do goThroughParts(v2) end end if v:IsA("Part") then -- This is where it actually does the comparison based on size local p = v.Position local s = v.Size local function getClosest(i, j, k, l) if (i + j > k + l and i - j < k + l) or (i + j > k - l and i - j > k - l) then return 0, 0 elseif(i + j < k - l) then return i + j, k - l elseif(i - j > k + l) then return i - j, k + l end end local closestX, closestPartX = getClosest(p.X, s.X / 2, part.Position.X, part.Size.X / 2) local closestY, closestPartY = getClosest(p.Y, s.Y / 2, part.Position.Y, part.Size.Y / 2) local closestZ, closestPartZ = getClosest(p.Z, s.Z / 2, part.Position.Z, part.Size.Z / 2) local magnitude = (Vector3.new(closestX, closestY, closestZ) - Vector3.new(closestPartX, closestPartY, closestPartZ)).magnitude if magnitude > lowestMagnitude then lowestMagnitude = magnitude partWithMagnitude = v end end end for i,v in pairs(workspace:GetChildren()) do goThroughParts(v) end print(partWithMagnitude)
Closed as Non-Descriptive by hiimgoodpack, blowup999, abnotaddable, and PyccknnXakep
This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.
Why was this question closed?