Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I print something that may or may not exist?

I have tried this (towards bottom) but for some reason it doesn't work if something doesn't have a value. Any ideas/help?

print("--Beginning of Stuff--")
local children = game.Workspace:GetChildren()
for i = 1, #children do
if children[i].Value then
   print("Type - " ..children[i].ClassName.. " | Name - " ..children[i].Name.. " | Value - " ..children[i].Value)
else
   print("Type - " ..children[i].ClassName.. " | Name - " ..children[i].Name.. " | Value -  N/A")
end
end
print("--End of Stuff--")

1 answer

local object = game.Workspace:FindFirstChild("intValue")

if object then
	if object.ClassName == "intValue" then
		print(object.Value)
	else
	    -- object exists, but is not an object of class "intValue".
	end
else
	-- object does not exist
end

This discussion is preserved as it was. New answers, comments, and votes are closed.