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

How do you make an if statement end the script if a condition is met?

Asked by 6 years ago

Title sort of explains all.

2 answers

Log in to vote
0
Answered by 6 years ago

You would use a break statement, search it on the wiki for more information.

0
Breaks only work with loops and skips through them, I meant something that ends the script entirely. IAmSoloz 14 — 6y
0
Ends the script entirely? You could just do script.Disabled = true if you wanted Vulkarin 581 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Here's an example, we will be using a BoolValue for this example that has just been changed to true. The script is a child of Boolvalue

script.Parent.Changed:connect(function() -- This just detects a change in a bools value, it does not need to be added.
    if script.Parent.Value == true then -- Replace "script.Parent.Value == true" with your statement.
        print("Condition met") -- Ends the script with a print.
    else
        print("Condition not met") -- If you want to put some code here if the bool does not meet the requirements then do.
    end
end)

Answer this question