i have a script that needs to go through a frame’s children and find a model
Every frame has a diffrent model, and i cant do “Name” i have to do sum like
:FindFirstChildThatIsA(“Model”) or somethin like that. idk if that exists but i need it
Thanks!
Simple, just use:
:FindFirstChildWhichIsA()
ok thank you so much!
do i just put the instance type like (Instance) or like (“Instance”)
You put it as a string, so for example if you’re trying to find a Model
inside a Folder
, you’d do:
local Folder = workspace.Folder
local Model = Folder:FindFirstChildWhichIsA("Model")
if Model then
-- do whatever
end
Also, just like :FindFirstChild()
, :FindFirstChildWhichIsA()
has an optional parameter for if you’d like it to be recursive and search through all descendants.
i jsut got
print(object:FindFirstChildWhichIsA("Model").Name)
and i go the error
“Attampt to index nil with name”
Wait i found the issue i think.
now i gotta learn ho to use tables and put instances in them, can you help with that?
i cant find anything on how to add what im trying to add to a table, so im going to make a devforum post for it.
local instanceTable = {}
local object --your object
if object:FindFirstChildWhichIsA("Model") then
for i,v in object:GetChildren()
if v:IsA("Model") then
table.insert(instanceTable, v)
end
end
end
pretty sure this would work (i had to code this with 1 hand since my other one is fractured)
oh im sorry mans, what happened to ur hand?
I fractured it a week ago skateboarding and only now just found out its fractured yesterday via an xray. (this is off topic though)
im sorry mans, i hope it heals. (idk if fractures heal)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.