Map duplicating to each player and not once for all server Please help

https://gyazo.com/2bee23b68878a6b904bbfdf40a226189

https://gyazo.com/f45ec32726de2c7c50889be9e09de61f

https://gyazo.com/ccee9a96099612b230bd86f4f1264c7d

i want only once map will duplicate for all server not for each player

as you can see in the example(video) i have two maps and i don’t want it
if someone can help and show me example of how fix it i appreciate it…

1 Like

Try using a server script instead of a local script.

1 Like

which local script? i have 2 scripts:

  1. Module Script
  2. Server Script

i didn’t used any local script
they are placed in the ServerScriptService.

1 Like

so do you want each player with their own map? then use local scripts and store the maps in replicatedstorage

if this doesn’t answer your question, my apologies. I don’t completely understand what you would like to do.

if you need a more detailed answer, you can reply to me

2 Likes

i want the game will choose random map and then clone it to the workspace and all players will have the same map

not like in the video that i put up, i tested 2 players game and the map was cloned to the workspace twice. and i want only once

1 Like

Show us your script and what type of script you are using.

1 Like

The scripts are in the Gyazo links. It’s a module script & a server script as mentioned in post 3.

1 Like


I think this is the reason, you are firing the function each time a new player is added that’s why you are getting duplicated maps

1 Like

how can i get player without using this?

you can use a table and PlayerAdded event like:

local players = {}
    game.Players.PlayerAdded:Connect(function(player)
       if not players[player] then
           table.insert(players,player)
           end
    end)

   game.Players.PlayerRemoving:Connect(function(player)
           table.remove(players,player)
    end)
1 Like

It might be the one line inside the while true do.

MyModule.ChooseMap(game.ReplicatedStorage.Maps:GetChildren())

This is probably running the ChooseMap a second time since it was already run the first time in the Module script.

and then i replace it in the “player” lines?

1 Like

and how can i fix that problem?

1 Like

you should make a for loop function that will loop through our table, then it will return the players one by one if needed, or you can make it like to run your player based lines in the function and once it’s done with it can process the code for the rest of the players

1 Like

i need to define player and then it will work?

but how the loop function will help?

1 Like

Actually I’m not sure about this, I have a question. How is there two maps for both the players/clients? In the gyazo gif you sent, there is only one map but it prints two different maps in the output. We only get to see a server camera view and partially a client view.

1 Like

https://gyazo.com/26a058df73c5f985bc4b4a761e782d0d

1 Like

when only one player in the server(game) it cloning him one random map

when two+ players in the server(game) it cloning it for each player and other players see other player maps too

1 Like

so a table can handle a lot of data within, but it doesn’t reference anything directly.
with a for loop we can loop through our table’s data and return or use them, here’s an example:

local players = {game.Players.RandomPlayer}

for index,value in pairs(players) do
local character = value.Character or value.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
if humanoid then
  humanoid.Health = 0
     end
end

this will loop through our table and kill any player inside of it

1 Like

ok but how can it fix my problem?

when only one player in the server(game) it cloning him one random map

when two+ players in the server(game) it cloning it for each player and other players see other player maps too

1 Like