local function GetInstanceByDebugID(DebugId:string) local function Proccesing() for i,v:Instance in pairs(game:GetDescendants()) do if v:GetDebugId() == DebugId then return v end end if not Proccesing() and DebugId == game:GetDebugId() then return game elseif Proccesing() ~= nil then return Proccesing() end end end local d = GetInstanceByDebugID("0_2085749") print(d)
for some reason it prints nil.
0_2085749 is the game’s debug id.
i used print(game:GetDebugId()) and it said “0_2085749”
But please @HenryThe_Legendary , do format your ‘commands’ nicely before bringing it here, we don’t want that extra work.
local function GetInstanceByDebugID(DebugId:string)
local function Proccesing()
for i,v:Instance in pairs(game:GetDescendants()) do
if v:GetDebugId() == DebugId then
return v
end
end
if not Proccesing() and DebugId == game:GetDebugId() then
return game
elseif Proccesing() ~= nil then
return Proccesing()
end
end
end
local d = GetInstanceByDebugID("0_2085749") print(d)
You did execute the main function, but you did not call Proccessing().
Here’s the formatted code (You can run code from scripts too, not just single-lines):
local function GetInstanceByDebugID(DebugId:string)
local function Proccesing()
for i,v:Instance in pairs(game:GetDescendants()) do
if v:GetDebugId() == DebugId then
return v
end
end
if not Proccesing() and DebugId == game:GetDebugId() then
return game
elseif Proccesing() ~= nil then
return Proccesing()
end
end
Proccesing() -- Runs the proccessing function.
end
local d = GetInstanceByDebugID("0_2085749")
print(d)