Ive been trying to make a game with a random generated map but it keeps spawning the same map each time and i dont know how to fix it
here is the function from my module script
function module:LoadMap(DelayTime:number,CustomSeed,SpawnCharacter:boolean,RandomGeneration,Coins)
local GeneralSize = 50
local mapxsize = 25
local mapysize = 26
local mapzsize = 25
local seed
local ExtraPosition = Vector3.new(0,15,0)
if CustomSeed == nil then
local Randomer = Random.new()
seed = Randomer:NextInteger(50,120000) / 3
else
seed = CustomSeed
end
workspace.GenerationData.Seed.Value = seed
print(tostring(seed))
local noisescale = 23
local amplitude = 15
local blocksize = 5
local xnoise = 0
local ynoise = 0
local znoise = 0
local AllParts = 0
local AllPartsFolder = workspace.AllParts
--print(AllPartsFolder)
for x = 0, mapxsize do
for z = 0, mapzsize do
for y = 0, mapysize do
xnoise = math.noise (x/noisescale, z/noisescale, seed) * amplitude
znoise = math.noise (z/noisescale, x/noisescale, seed) * amplitude
local density = xnoise + znoise - y
if density < 5 and density > 2 then
AllParts = AllParts + 1
end
end
end
end
task.wait()
workspace.GenerationData.MaxParts.Value = tonumber(AllParts)
if AllParts > 1250 then
for x = 0, mapxsize do
for z = 0, mapzsize do
for y = 0, mapysize do
xnoise = math.noise (x/noisescale, z/noisescale, seed) * amplitude
znoise = math.noise (z/noisescale, x/noisescale, seed) * amplitude
local density = xnoise + znoise - y
--print()
if density < 5 and density > 2 then
if RandomGeneration["Enabled"] == true then
task.spawn(function()
task.wait(math.random(8,RandomGeneration["SpawnTime"])/10)
local part = Instance.new ("Part",AllPartsFolder)
if math.random(1,3) ~= 2 then
part.Color = Color3.fromRGB(150, 150, 150)
part.Material = Enum.Material.Snow
else
part.Color = brightColors[math.random(1,#brightColors)]
part.Material = Enum.Material.SmoothPlastic
end
part.Anchored = true
part.Size = Vector3.new (blocksize, blocksize , blocksize)
part.CFrame = CFrame.new (x*blocksize, y*blocksize + ExtraPosition.Y , z*blocksize)
workspace.GenerationData.CurrentParts.Value = workspace.GenerationData.CurrentParts.Value + 1
local OldPos = part.CFrame
task.spawn(function()
--SpawnBlockDown(OldPos,{BlockSize = blocksize,Folder = AllPartsFolder})
end)
end)
end
end
end
end
if DelayTime ~= nil then
task.wait(tonumber(DelayTime))
end
end
repeat
task.wait()
until workspace.GenerationData.CurrentParts.Value == workspace.GenerationData.MaxParts.Value
local Blacklisted = {}
task.wait()
for i = 1,Coins do
local Coin
if math.random(1,5) == 3 then
Coin = game.ServerStorage.Diamond:Clone()
else
Coin = game.ServerStorage.Coin:Clone()
end
Coin.Parent = workspace.Extra
local Position
local EditPos
repeat
local Selected = AllPartsFolder:GetChildren()[math.random(1,#AllPartsFolder:GetChildren())]
if Selected:IsA("Part") then
Position = Selected.Position
EditPos = Vector3.new(Position.X,0,Position.Z)
else
-- not a part
task.wait()
end
until Position ~= nil and type(table.find(Blacklisted,EditPos)) ~= type(1)
Coin:MoveTo(Position)
table.insert(Blacklisted,EditPos)
end
print("Done",workspace.GenerationData.CurrentParts.Value, seed)
workspace.GenerationData.CurrentParts.Value = 0
SpawnBlockDown(RandomGeneration["SpawnTime"])
if SpawnCharacter then
for i,v in pairs(game.Players:GetPlayers()) do
v:LoadCharacter()
end
game.Players.CharacterAutoLoads = true
end
else
print("Small map")
module:LoadMap(DelayTime,CustomSeed,SpawnCharacter,RandomGeneration,Coins)
end
end
I know the code is messy but thats because i need to have logs of reports