I am wondering if this is an efficient way to do it.
local dialogchoice
while not dialogchoice do
wait()
pcall(function()
dialogchoice = script.Parent.Dialog.DialogChoice.DialogChoice.DialogChoice.DialogChoice.DialogChoice.DialogChoice
end)
end
The script is in the head of an NPC.
I am just wondering if this is an efficient way to do it or if there’s a better way.
and so on and so on.
After that, all you should need to do is call;
local Dialog = script.Parent.Dialog
local DEPTH = 1 -- or 2,3,4... however deep you're trying to search.
local dialogchoice = Dialog:FindFirstChild("DialogChoice"..DEPTH, true)
--[[FindFirstChild(OBJ, true) will search through all descendants to find a value.
If nothing exists, it returns nothing]]