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

Making a automatic team choosing system but math.random keeps repeating?

I am making a automatic team choosing system and I am using :GetPlayers() to do this

I need some players to be humans and some to be zombies

however math.random is constantly repeating what do you guys suggest I do?

1 answer

If you're setting a variable to math.random, it will have the same value every time the script repeats. Example:

local random = math.random(1, 10)

print(random)
print(random) 
-- These will both print the same thing.

What you should do is make a function for getting a random number. For example:

function getRandom(number1, number2)
  return(math.random(number1, number2))
end

print(getRandom(1, 10))
print(getRandom(1, 10))

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