Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is if not success then is used?

Asked by 5 years ago

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

0
It's used to check if the script failed. cutecatgirl1557 20 — 5y
0
or in case of datastores have a 'backup' system User#20388 0 — 5y
0
basically you mean its used in pcalls to check if the call succeeded or not SulaymanArafat 230 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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!

Ad

Answer this question