How do I check if a child of something exists. A example would be if a script exists under a part and if it does then it does something. I’ve tried stuff like if script.Parent.ClonedScript then … But it just errors. How do I make it NOT error and just check if clonedscript exists?
1 Like
You can use something like
local model = workspace.Model
if model:FindFirstChild("Part") then
print("Part exists")
else
print("Part does not exist")
end
2 Likes
Something like this?
if script.Parent:FindFirstChild('ClonedScript') ~= nil then
-- code
end
Two methods.
for i,v in pairs(Model:GetChildren()) do -- Replace "Model" with the parent's name
if v then
return true
end
end
if Model:FindFirstChild(v) then -- Replace "v" with the child's name
return false
else
return true
end
2 Likes
All of you had great responses and I thank you very much!!