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

Why is my 2nd "if" part of randomizer script doesnt work???

Asked by 2 years ago

So the part of script when number is 1 is working great, but when its 2 its dont work. Output dont say anything. Please i beg you for help! Script:

local text = game.Workspace.LuckyMonitor.SurfaceGui["Try Luck!"]
local luck = game.Workspace.Luck
local fail = game.Workspace.Fail
local cooldown = false
script.Parent.ClickDetector.MouseClick:Connect(function()
    if cooldown == false then
    cooldown = true
    text.Text = "Wait"
    wait(5)
--WORKING PART!
    local chance = math.random(1,2)
    if chance == 1 then
    text.Text = "Lucky!"
    text.TextColor3 = Color3.new(0, 1, 0)
    if not luck.IsPlaying then
    luck:Play()
    print("LUCK!")
    wait(3)
    text.Text = "Try Your Luck"
    text.TextColor3 = Color3.new(0,0,0)
    cooldown = false
--NOT WORKING PART!
            else 
    if chance == 2 then
    text.Text = "Failure!"
    text.TextColor3 = Color3.new(1, 0, 0)
    if not fail.IsPlaying then
    fail:Play()
    print("Fail")
    wait(3)
    text.Text = "Try Your Luck"
    text.TextColor3 = Color3.new(0,0,0)
    cooldown = false
                    end
                end
            end
        end
    end
end)

2 answers

Log in to vote
0
Answered by 2 years ago

maybe you should try "elseif" statements instead of many "if" statements continuously

0
Thanks may try it later, can you rewrite the scripts? :D SashaPro336 47 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

In line 23, You have else by it self and if under it in line 24, use this in line 24 and delete line 23.

            elseif chance == 2 then

I wish I helped!

Answer this question