Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I really use a Region3.new?

Asked by 8 years ago

Hey there, I want to make a Region3 and then it prints the name of all the parts inside of the Region3 however, I have no idea how I could make it to where it prints all the parts inside of the Region3 I know how to make one...

local player = game.Players.LocalPlayer
local char = player.Character
local mouse = player:GetMouse()


function getParts(origin, radius)
if key == 'q' then
local a = origin - Vector3.new(radius, radius, radius)
local b = origin + Vector3.new(radius, radius, radius)
local region = Region3.new(a,b)
local parts = region:findPartsOnRegion3(
region,
char,
100)
end
end

function activateSkill(radius)
--This is what I don't know what to do in order to print all the parts name in that region.
end

mouse.KeyDown:connect(getParts)

Thank you for reading my question all the way and I hope at least one of you can help me out with this issue I have.

1 answer

Log in to vote
1
Answered by 8 years ago

Create a pairs loop and iterate through the parts that are in the table. Although your region is local to your getParts scope so it wont see it in your activeSkill function. Either make it global or do it all in one. Also the method is findPartsInRegion3, not onRegion3


for _,v in pairs(region:findPartsInRegion3(region,char,100) do print(v.Name); end
Ad

Answer this question