Math.random issue

Heya! So I have a door that opens with a script and the aim is for it to pick a number 1-2.

If it picks 1 scenario A will happen.
If it picks 2 scenario B will happen.

for now, we have it just printing a string of text.

Any help is appreciated, right now it’s plagued with different issues each time we test.

wait(0.1)
m = workspace.Doors.Door1.Motor.Motor
m.DesiredAngle = 1.6


math.random(1,2)



if 1 then
	print "Loose"
else
	print "Yay"
end  

^ This script is located in StarterPlayerScripts
Any help with fixing this issue is appreciated. Thank you!

Currently, you’re just tossing away the number you grab.

wait(0.1)
m = workspace.Doors.Door1.Motor.Motor
m.DesiredAngle = 1.6

local randomNumber = math.random(1,2) --Store our number in a variable

if randomNumber == 1 then --Make use of the variable to check the number we were given.
	print("Loose")
else
	print("Yay")
end  
1 Like

Hey! It’s working but now printing both scenarios:
image

Nevermind. My error, sorry all fixed.