Hey, so I have a model, and when there are a certain amount of players it gets cloned and the players get teleported to spawn points inside of the model. Inside the model there are a bunch of obstacles and when the player dies I want them to spawn back in the same model at a spawn point. I don’t know how to make them spawn back in the same model and not a different one because there will be multiple of the same models, as the model will keep cloning as more players join. Sorry if I didn’t explain this very well.
Script that teleports the players to the model
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Arena = ServerStorage:WaitForChild("Arena")
local plots = ServerStorage:WaitForChild("VaultPlots"):GetChildren()
while true do
local full = false
local waiting = {}
local plrs = {}
game.ReplicatedStorage.AddPlayerToTable.OnServerEvent:Connect(function(player)
if full == true then
table.insert(waiting,player)
else
table.insert(plrs,player)
end
end)
if full == false then
for i, player in pairs(waiting) do
table.insert(plrs,player)
table.remove(waiting,player)
end
end
repeat wait(1) until #plrs == 1
full = true
for i, plot in ipairs(plots) do
if plot.Bool.Value == false then
position = plot.CFrame
plot.Bool.Value = true
break
end
end
local ClonedArena = Arena:Clone()
ClonedArena.Parent = workspace
ClonedArena.PrimaryPart = ClonedArena.ArenaGround
ClonedArena:SetPrimaryPartCFrame(position)
ClonedArena.Status.Value = true
local SpawnPoints = ClonedArena:FindFirstChild("SpawnPoints")
local AvailableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
character.HumanoidRootPart.CFrame = AvailableSpawnPoints[1].CFrame
table.remove(AvailableSpawnPoints,1)
table.remove(plrs, i)
game.ReplicatedStorage.WaitScreenEnd:FireClient(player)
end
end
end
if #plrs == 3 then
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
character.HumanoidRootPart.CFrame = AvailableSpawnPoints[1].CFrame
table.remove(AvailableSpawnPoints,1)
table.remove(plrs,i)
i -= 1
game.ReplicatedStorage.WaitScreenEnd:FireClient(player)
end
end
end
end
if #plrs == 1 then
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
character.HumanoidRootPart.CFrame = AvailableSpawnPoints[1].CFrame
table.remove(AvailableSpawnPoints,1)
table.remove(plrs,i)
i -= 1
game.ReplicatedStorage.WaitScreenEnd:FireClient(player)
end
end
end
end
full = false
end