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

Why won't this work?

I'm practicing my returning and functions and printing, but for some reason, when I test it, it doesn't show the values after beef. burgers=854649

function cheese()

    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")
    print ("lettuce")

return "beef" 

end

print (burgers) burgers=cheese print (cheese())


2 comments

0

What do you mean the values after beef? It starts printing things at line 17. It prints the value of the variable burgers, then runs through the function cheese and prints the returned beef. What else is it suppose to print?

0

Thats the problem. It DIDNT print things after beef.

1 answer

Nothing is wrong.

The output is this, correctly:

854649
lettuce
lettuce
lettuce
lettuce
lettuce
beef

Line 18 in the snippet you posted doesn't really matter, since you don't use burgers after that. You can remove it.

burgers = 854649

function cheese()
	print ("lettuce")
	print ("lettuce")
	print ("lettuce")
	print ("lettuce")
	print ("lettuce")
	return "beef" 
end

print(burgers) -- 854649
print( cheese() )
	-- cheese() prints:
		-- lettuce, lettuce, lettuce, lettuce, lettuce
		-- `cheese()`returns "beef"
	-- prints evaluation of `cheese()` which is "beef"

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