My button script has a function that will teleport players if it has spawn points in it. But, it only teleports one player, help..?
Here's the script:
local db = true
local module = require(game.ServerStorage.Data)
script.Parent.MouseClick:Connect(function()
if db == true then
db = false
for i, player in pairs(game.Players:GetPlayers()) do
if player then
local plrs = {}
table.insert(plrs,player)
local maps = game.ServerStorage.Maps
local availableMaps = maps:GetChildren()
local chosenMap = availableMaps[math.random(1,#availableMaps)]
local clonedMap = chosenMap:Clone()
game.Workspace.Intermission:Stop()
clonedMap.Parent = workspace
if clonedMap.Name == "Nebula" then
game.Workspace.Part.Transparency = 1
else
--// Do nothing
end
if clonedMap:FindFirstChild("SpawnPoints") then
local spawnPoints = clonedMap.SpawnPoints
local availableSpawns = spawnPoints:GetChildren()
player.Character.HumanoidRootPart.CFrame = availableSpawns[1].CFrame
table.remove(availableSpawns,1)
else
--// Do nothing
end
if clonedMap:FindFirstChild("SkyBox") then
clonedMap.SkyBox.Parent = game.Lighting
end
script.Parent.Parent.BrickColor = BrickColor.new("Bright red")
wait(module.ButtonTime)
player.Values.Points.Value = player.Values.Points.Value + 100
if game.Lighting:FindFirstChild("SkyBox") then
game.Lighting.SkyBox:Destroy()
end
game.Workspace.Intermission:Play()
script.Parent.Parent.BrickColor = BrickColor.new("Bright green")
if clonedMap:FindFirstChild("SpawnPoints") then
player:LoadCharacter()
end
if game.Workspace.Part.Transparency == 1 then
game.Workspace.Part.Transparency = 0
end
clonedMap:Destroy()
db = true
end
end
end
end)

2 comments
You know, you try to copy the Map for each player?
what do you mean?