I was recently working on a plugin, that I wanted to rework. I made a modulescript with functions, and one of the functions uses :GetDescendants(), however it’s not working how it’s supposed to.
Function Code:
function module.CheckIfObjectExists(objectname : string)
for i, desc in pairs(game:GetDescendants()) do
if desc.Name == objectname then
return true
end
end
return false
end
function module.CheckIfObjectExists(objectname : string)
for i, desc in pairs(game:GetDescendants()) do
if desc.Name == objectname then
return true
else
return false
end
end
end
Ah, my bad. Try this, I doubt it will work but worth a try
local Exists = false
function module.CheckIfObjectExists(objectname : string)
for i, desc in pairs(game:GetDescendants()) do
if desc.Name == objectname then
Exists = true
else
Exists = false
end
end
return Exists
end