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

How can you use return for conditional statements?

Can you do this?

local function Search(Location, Value)
if Location[Value] then
local status = “found”
return(status)
end
end

local SearchStatus = Search(workspace, Part)
print(SearchStatus)

2 comments

0

yes

0

Yeah, but you don't have to put status in parentheses/brackets. You can just do "return status".

1 answer

✓ Accepted answer

Yes, you can do this. Very useful for classifying objects, too:

function isItLimeGreen(thing)
	if thing.BrickColor = BrickColor.new("Lime green") then
		return "True"
	else
		return "False"
	end
end

local object = game.Workspace:FindFirstChild("Test")
print( isItLimeGreen(object) )

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