I've noticed that although math.random is in fact random, I have noticed that the same object gets picked each and every time I disable/enable my script. How can I make math.random more random so that it doesn't replicate upon disabling/enabling the script. Here is what I have
players = game.Players:GetChildren() local randomplayer = players[math.random(1, #players)]
Make a function to retrieve the randomplayer. Then you will make sure it will always be random.
local function GetRandomPlayer() local players = game.Players:GetChildren() local randomplayer = players[math.random(1, #players)] return randomplayer end local randomplayer = GetRandomPlayer()
math.random will be the same sequence or a similar one every time. One the wiki you can find a better explanation for this, but a simple solution would be putting math.randomseed(tick())
at the start of the script.