I am trying to make zombies spawn in random locations (there are 4 at the moment) and they always spawn at the same place. I tried making this custom function to try to make numbers more random but it is not working.
Every time I do a new test session in studio the number changes but it always repeats the same number.
function GetRandom(Num1, Num2)
local Nums = {}
math.randomseed(tick())
for i = 1,100 do
local Math1 = math.random(Num1,Num2)
Nums[i] = Math1
end
local Math2 = math.random(1,100)
return Nums[Math2]
end
module.PrepareZombie = function(Name)
local Zombie = Zombies[Name]:Clone()
Zombie.Parent = ZombieFolder
local Spawn = GetRandom(1,#Spawns:GetChildren())
print(Spawn)
Spawn = Spawns:GetChildren()[Spawn]
Zombie.HumanoidRootPart.CFrame = Spawn.CFrame
ZombieCore.Reincarnate(Zombie)
end

4 comments
Roblox naturally gives you random values by generating random seeds.
There is no reason whatsoever for that function to exist. Does math.random(1, #Spawns:GetChildren()) not work?
As a side note, randomizing a set of random numbers doesn't make your random more random. Random?
Are you using the module PrepareZombie function in a server script? If you are, try putting math.randomseed(tick()) at the top instead of in the GetRandom function. Try removing it from the function and putting it in the script you’re using PrepareZombie in as one of the first lines. In all of my scripts needing to use math.random, I always put math.randomseed(tick()) at the top before anything