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

Why is if not success then is used?

so if not success then is sometimes used on other scripters, but why it is used? it is only used to know an error?

3 comments

0

It's used to check if the script failed.

0

or in case of datastores have a 'backup' system

0

basically you mean its used in pcalls to check if the call succeeded or not

1 answer

Here we set up for that situation:

local success, message = pcall(function()

	-- Let us say I have a script that does not need to work but I want to know if it fails in here

end)

if not success then

	print("Non crucial code failed error is: "..message)

end

This time I don't want to do anything if it is successful so I use if not success so that it only passes the if statement if there was a failure. I hope this helps and have a great day scripting!

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