i want only one map will be cloned for whole server
1 Like
Can you show us the workspace & location of where the maps are parented to?
1 Like
so you will fire the function once, and you will have your player list without using PlayerAdded
to fire your code
EDIT1
and that for loop function
will help you to run your player based code
1 Like
Sorry I’m asking but you can do the script to understand more?
2 Likes
alright here is an example:
local PlayerList = {}
function MyPlayerLoop(MyArguments) --Any code that players are involved in like adding a screen GUI in their PlayerGui folder
for index,player in pairs(PlayerList) do
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
if Humanoid and Humanoid.Health > 0 then
Humanoid.Health = 0
end
end
end
function MyFunction(MyArguments) -- your code
while wait(5) do
MyPlayerLoop("MyArguments")
end
end
game.Players.PlayerAdded:Connect(function(player) -- adding new players to the table
if not PlayerList[player] then
table.insert(PlayerList,player)
end
end)
game.Players.PlayerRemoving:Connect(function(player) --removing the player once they leave
if PlayerList[player] then
table.remove(PlayerList,player)
end
end)
MyFunction("MyArgs") -- Firing your main function once
Edit1
simply, this code will kill any player in our table every 5 seconds
1 Like