|
| 28 Jul 2014 04:21 AM |
--Is there a better way to do this cause this like to error and break sometimes.
--This function makes it so you won't use the same number twice in a row. ln = nil
function Num() ln = math.random(1,4) if ln == script.Last_Num.Value then wait() print'Re-Try' Num() return end script.Last_Num.Value = gt end
Num() |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2014 04:29 AM |
local last_used = 0
function use() local new_num = 0 repeat new_num = math.random(1,4) until last_used ~= new_num -- generates a new number until it isn't the last one. end
The return keyword breaks the function. It returns the value and stops all execution afterwards.
If you were to do it via player input...
local last_used = script.Last_num
function use(number) if(last_used.Value == number)then print("Retry") return end last_used = number end end
use(3)
|
|
|
| Report Abuse |
|
|
| |
|