#looping through a folder

1 messages · Page 1 of 1 (latest)

queen rapids
#

any idea how im supposed to loop through this whole folder for all of the parts only for my raycast?

#
local Position = script.Parent.Parent.Mouth2.Position
local Direction = script.Parent.Parent.Mouth2.CFrame.LookVector * 100
local rayresult = workspace:Raycast(Position,Direction)
local raycastparams = RaycastParams.new()
raycastparams.FilterDescendantsInstances = {workspace.Plants.Peashooter}
raycastparams.FilterType = Enum.RaycastFilterType.Exclude```
#

my script rn

cerulean delta
#

uhmm

#

cant u just do a for loop

queen rapids
#

i mean i tried it didnt rlly work

cerulean delta
#

try this

#

so what are u tryna get

queen rapids
#

im tryna exclude all of the parts in the folder

#

so im tryna get all of the parts

cerulean delta
#

for i,v in plants:GetDescendants() do if v:IsA(“Part”) then code end end

#

plants being a variable for the folder

#

notice this only tags the parts not baseparts which include stuff like spheres, wdges and other

queen rapids
#

how am i supposed to get "v" out side the scripts then

cerulean delta
#

bruh wlr

#

local x

for i,v in plants:GetDescendants() do
if v:IsA(“Part”) then
code x = v
end
end
more code

queen rapids
#

but thing is

#

you cant just plug v

#

or x in that case

cerulean delta
#

u can

queen rapids
#

inside the raycast filtertype thing

cerulean delta
#

o

queen rapids
#

arent u supposed to return it

cerulean delta
#

I thought u meant u just needed the parts

#

well then u could put it in a function and return v

queen rapids
#

i mean yea but im not tryna look through it every time it runs

#

loop*

cerulean delta
#

the function will then become v

queen rapids
cerulean delta
#

then the function itself will refer to v

tardy breach
#

hypothetically, use folders for what they're for

cerulean delta
#

so you could then type

tardy breach
#

put all things of the type you want into a singular folder

cerulean delta
#

print(raycastParts().Name)

tardy breach
#

Do getchildren

#

ez

cerulean delta
#

uh

queen rapids
#

hm

#

uk what i think i thought of another solution

queen rapids
half lark
#

so what exactly r u trying

#

to get the parts?

#

or to have them in a singular variable

queen rapids
tough fiber
# queen rapids this

the property of raycastparams is named filterDescendantsInstances, if you just add the folder then everything under the folder in the hierarchy will get ignored

queen rapids
tough fiber
#

yeah

queen rapids
#

Didn't work

royal marshBOT
#

studio** You are now Level 17! **studio

queen rapids
#

The peashooter is somehow still shootig

tough fiber
#

uhh

#

are you making the parameters after you raycast?

queen rapids
#

No it's before

tough fiber
#

doesn't seem like it to me

queen rapids
#

Ah

#

Lemme try

#

Doing it before

tough fiber
#

well yeah

#

you do it before

#

and you pass in the parameters to the function

queen rapids
#

Still ain't working

#

Ok so this is what I tried

#

I put string values in the peashooter itself named plant and string values in the dummies named zombies

#

When the dummy is on the exact lane the peashooter behind is supposed to print is a zombie, however it somehow doesn't detect it

#

And note the dummy isn't inside workspace.gardens so idk what's going on