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

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

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

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

1 comment

0

Thanks may try it later, can you rewrite the scripts? :D

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!

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