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

Help With A Value Issue?

Asked by
Scootakip 299 Moderation Voter
8 years ago
RN.Value = (math.random(7))
if RN.Value == LRN.Value then
    print "Same Number!"
    while RN.Value == LRN.Value do
    RN.Value = (math.random(7))
    end
elseif RN.Value ~= LRN.Value then
    print "New Number!"
end
print(RN.Value)
LRN.Value = RN.Value

RN = Room Number LRN = Last Room Number

That script above is made so that the same room number can't be generated twice in a row. If it is, it's supposed to keep generating numbers until it gets a new number, but it doesn't work. It always prints 'New Number!' even when it's the same number as last time. Can someone help me fix this to work properly? Thanks.

0
The code you posted does work as intended. You must have something else that's interfering with the outcome. Programmix 285 — 8y
0
Yeah, you're right. I just found out what was interfering with it. It's such a silly mistake it would literally be embarrassing if other people knew what the error was, lol. Thanks though! Scootakip 299 — 8y

Answer this question