generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: how to check every part in a 15-stud radius

Previous Thread :: Next Thread 
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
01 Jun 2014 01:53 AM
how do i check for each part in a 15-stud radius, i know it uses magnitude but whats the function used to check for everything in the radius? Do i have to get every single part in workspace and check if its in the radius zone? Would that lag?
Report Abuse
IAmTheRolo is not online. IAmTheRolo
Joined: 12 Nov 2013
Total Posts: 859
01 Jun 2014 01:56 AM
Why not use Region3's?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Jun 2014 01:57 AM
Because Region3's don't support "radius" since they are rectangular, not circular.

OP, just loop through all parts (recurse if you have to) and compare.
Report Abuse
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
01 Jun 2014 02:22 AM
can you give me an example of region3 that might help me
Report Abuse
Wreckerbuster67 is not online. Wreckerbuster67
Joined: 29 Jul 2012
Total Posts: 1144
01 Jun 2014 02:35 AM
local part = game.Workspace.Part
local range = 15
PartsInRadius = {}

function CollectDescendants(model)
local collected = {model}
if model:GetChildren() then
for i,v in pairs(model:GetChildren()) do
table.insert(collected, v)
if v:GetChildren() then
CollectDescendants(v)
end
end
end
table.remove(collected, part)
return collected
end

subjects = CollectDescendants(game.Workspace)

for _,obj in pairs(subjects) do
if obj:IsA("BasePart") then
local dst = (part.CFrame - obj.CFrame).p.magnitude
if dst <= magnitude then
table.insert(PartsInRadius, obj)
end
end
end
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
01 Jun 2014 02:46 AM
@above
Second function, if line: if dst <= magnitude then
Change the 'magnitude' to 'range', you used the wrong variable name.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image