of     1   

nofascistsaloudxD
#228418755Monday, December 04, 2017 6:08 AM GMT

I would post the script I attempted to create, but ROBLOX'S FILTER KEEPS TAGGING IT! Anyway... Anyone have any suggestions to creating a script that that checks the workspace for models, checks the models for torsos, then keeps two torso in a table. The first torso is the one closest to the AI, and the second torso is the one secondly closest to the AI... My original script was useless in doing this..
Railmints
#228419345Monday, December 04, 2017 6:38 AM GMT

I suggest using a region 3, then finding which parts inside are named torso.
nofascistsaloudxD
#228419427Monday, December 04, 2017 6:43 AM GMT

@Railmints I have very basic information on region3. All I know is that it returns the values within a region. Care to explain it further please?
Railmints
#228419479Monday, December 04, 2017 6:47 AM GMT

a region3 is just a cubicle region that you make by doing region3.new(Vector3,Vector3). The two vector3s will set the Corners for the cubes boundaries and if you have any questions about that the wiki has some pictures to show you what i mean. with a region3 you can find all the parts that are inside it with game.Workspace:FindPartsInRegion3(region3,ignoredescendants,numberofparts) this will return a table with how ever many parts are inside the region up to the amount specified in the last parameter.
nofascistsaloudxD
#228419494Monday, December 04, 2017 6:48 AM GMT

@Railmints Thanks, man.
128Gigabytes
#228419528Monday, December 04, 2017 6:50 AM GMT

Here is some efficiency overkill since we know how taxing a lot of npc's can be. local getTorsos; do local descendants = game.Workspace:GetDescendants() local allTorsos = {} for x = 1, #descendants, 1 do if (descendants[x].Name == "Torso") then allTorsos[#allTorsos + 1] = descendants[x]; end end game.Workspace.DescendantAdded:connect(function(descendant) if (descendant.Name == "Torso") then allTorsos[#allTorsos + 1] = descendant; print(#allTorsos) end end) function getTorsos(position, ignore) local output = {} local cleanup = {} local ignore = (ignore or {}) for x = 1, #allTorsos, 1 do local torso = allTorsos[x] if (torso.Parent == nil) then cleanup[#cleanup + 1] = x elseif (not ignore[torso]) then output[#output + 1] = {torso; (torso.Position - position).magnitude;}; end end for x = #cleanup, 1, -1 do table.remove(allTorsos, cleanup[x]) end table.sort(output, function(torso0, torso1) return (torso0[2] < torso1[2]); end) return (output) end end while true do wait(1) --[[I don't suggest you actually do it this fast if you don't need to but this is just for the example.]] local torsos = getTorsos(Vector3.new(0, 10, 0), { --[[This Vector3 can be replaced with game.Workspace.npc.Torso.Position]] [game.Workspace.npc.Torso] = true; --[[Example of how to not include itself, since it will always be closest to itself.]] }) if (#torsos > 0) then --[[Make sure it found something.]] print("________") local nearestTorso = torsos[1][1] --[[Example of how to get the closest torso from the list.]] local nearestTorsoDistance = torsos[1][2] --[[Example of how to get the closest torsos distance.]] for x = 1, #torsos, 1 do print(torsos[x][1].Parent.Name) end --[[Example of how to print all the torsos characters names in order of distance. (Closests first.)]] end end
nofascistsaloudxD
#228419545Monday, December 04, 2017 6:51 AM GMT

Thanks, @128Gigabytes
Railmints
#228419560Monday, December 04, 2017 6:52 AM GMT

np yo

    of     1