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

Code doesn't work with elseif donutcode.Value == 1?

Asked by 4 years ago

So this script is supposed to parent a part to workspace every 5 seconds, I was doing a test run to make sure the code works but nothing is printed when active is true. Here's my code;

local active = script.Parent.active
local donutfolder = game.ServerStorage.donuts
local donutcode = script.Parent.donutcode
while true do
    if active.Value then 
    elseif donutcode.Value == 1 then --> This is the line of code I know is causing it.
    print("peter 'allah' griffin")
    else
      warn('inactive11!!!!1!')
        end
wait(5)
    end

Check line 6. How can I change line 6 so the print below it works?

0
Try getting rid of the else in the elseif I think vortex767 20 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

I think the problem is that you are checking first if active.Value is true ... which looks like it is true because its skipping the elseif's statements.

To test this out go to the active which is script.Parent and remove its value to make it false or nil, this will make the elseif run.

Unless you want both if statements to run so if active.Value is true check donutcode.Value your code then should look like this

local active = script.Parent.active
local donutfolder = game.ServerStorage.donuts
local donutcode = script.Parent.donutcode

while true do
    if active.Value then
        if donutcode.Value == 1 then
            print("peter 'allah' griffin")
        else
            warn('inactive11!!!!1!')
        end 
    end
wait(5)
end
0
This doesn't warn if active is false and donutcode is 0. VoidKeyword 111 — 4y
0
i know that , u just didn't clarify what you want the script to do. Mikael20143 138 — 4y
0
you have to do separate if statements for each condition in that case. nothing complicated Mikael20143 138 — 4y
Ad

Answer this question