I need help with destroying a map

Στιγμιότυπο οθόνης 2023-09-26 211209

For some reason the command you wrote spawns my player under the map

erm… I don’t think print() can do that
it was probably another piece of code teleporting you or something

I didn’t add print() In the script

Is this supposed to be a constant round system or just ran once?

A round system not ran once… It chooses a map

Why not employ a while loop to ensure the round system continues looping indefinitely?

Do you have any experience with modules, and classes? Probably a long shot question but asking just incase

1 Like

I got a problem AGAIN,So the script works

But it chooses the same map all the time

Can you help me with this???

How many maps do you have in the maps folder inside of replicatedstorage?

Its in ServerStorage I got 4 maps in the folder

You are choosing a map in the start of the script, so it stays the same for the server. Make a random selection when the game starts

Your doing everything correctly random wise, try shuffling the maps using the Fisher Yates algorithm first and then getting a random map

what do you mean Fisher Yates?? can you explain?

Just make a random selection everytime the round starts, no need for extra algorithms

the Fisher Yates algorithm basically shuffles elements inside of an array, in your case the array is the maps folder and the elements are the map models them selves, so we could do something like this

Instead of using another array we are directly shuffling the elements

local Maps = game.ServerStorage.Maps:GetChildren()
local numMaps = #Maps

for i = 1, numMaps do
    local randomIndex = math.random(i, numMaps)
    Maps[i], Maps[randomIndex] = Maps[randomIndex], Maps[i]
end

Why do you even need to shuffle?

local randomMap = Maps[math.random(1,numMaps)]

Where do I put this when the round starts?

You don’t need to use that shuffling