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

Can someone help me with this random.math script because its only working for one of the valiues?

Hello,

I am trying to make a math.random() values but its only taking 1 and not 2 why?

script.Parent.Bet.Conrim.MouseButton1Click:Connect(function()
	script.Parent.mainFrame.Reward.MoneyToGet.Value = script.Parent.Bet.Bet.Text
	script.Parent.Bet.Visible = true
	local WinningColor = math.random(1,3)
	if WinningColor == 1 then
		for i = 1,3 do
			script.Parent.mainFrame.Green.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			wait(.3)
			script.Parent.mainFrame.Red.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Green.BackgroundTransparency = 0
			wait(.3)
			script.Parent.mainFrame.Green.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Red.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0
			wait(.3)
			script.Parent.mainFrame.Green.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Red.BackgroundTransparency = 0
			wait(.3)
		end
		if WinningColor == 2 then
			for i = 1,3 do
		    script.Parent.mainFrame.Green.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			wait(.3)
			script.Parent.mainFrame.Red.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Green.BackgroundTransparency = 0
			wait(.3)
			script.Parent.mainFrame.Green.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Red.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0
			wait(.3)
			script.Parent.mainFrame.Green.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Red.BackgroundTransparency = 0
			wait(.3)
			script.Parent.mainFrame.Black.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Red.BackgroundTransparency = 0.6
			script.Parent.mainFrame.Green.BackgroundTransparency = 0
			wait(.3)
			end
		end
    end
end)

2 comments

0

It's random, test it like 50 times, we'll talk again if 3 doesn't appear

0

And your script only had 'if's condition for 1 and 2, 3 will be useless.

1 answer

The if statement for 2 will never run because it's inside of if WinningColor == 1 statement.

Put your second if statement outside of the first one and you're good

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