moves = {1; 2; 3; 4}
w = script.Parent
m1 = w.Move1 --These are string values.
m2 = w.Move2
m3 = w.Move3
m4 = w.Move4
function r(n)
return math.random(n)
end
m1.Value = moves[r(#moves)]
m2.Value = moves[r(#moves)]
if m2.Value == m1.Value then
while m2.Value ~= m1.Value do
m2.Value = moves[r(#moves)]
end
end
m3.Value = moves[r(#moves)]
if m3.Value == m1.Value or
m3.Value == m2.Value then
while m3.Value ~= m1.Value and
m3.Value ~= m2.Value do
m3.Value = moves[r(#moves)]
end
end
m4.Value = moves[r(#moves)]
if m4.Value == m1.Value or
m4.Value == m2.Value or
m4.Value == m3.Value then
while m4.Value ~= m1.Value and
m4.Value ~= m2.Value and
m4.Value ~= m3.Value do
m4.Value = moves[r(#moves)]
end
end
So what this script is supposed to do is to choose a member of the table and make the string values one of them. Now, this works, except for the fact that some of the members chosen are the same.
Any ideas anyone?
Any form of help is greatly appreciated!
Thanks!
P.S.
Before you say anything, no, math.random does not require two numbers. When only one number is given, It will choose a random number from 1 until the number given.

1 comment
They are all the same because you have loops ensuring they are all the same