I am currently making a game but I set up a round system and it will clone a folder from ServerStorage but I can't make it delete all the models that were spawned in here is my code:
local RoundLength = 180 local IntermissionLength = 60 local Lobby = workspace.LobbySpawn.Lobby.CFrame local Spawnpoints = workspace.GameSpawnPoints:GetChildren() local Brigatine = game.ServerStorage.Boats local RespawnTime = 2.5 local InRound = Instance.new("BoolValue") InRound.Name = "Inround" InRound.Parent = game.ReplicatedStorage local Status = Instance.new("StringValue") Status.Name = "Status" Status.Parent = game.ReplicatedStorage local function SpawnPlayer(Character, _CFrame) if InRound.Value == true then for _, object in pairs(Brigatine:GetChildren()) do Brigatine = object:Clone() Brigatine.Parent = workspace end else end local Root = Character:WaitForChild("HumanoidRootPart") if _CFrame then repeat Root.CFrame = _CFrame + Vector3.new(0, 4.5, 0) wait() until (Root.Position - _CFrame.Position).Magnitude < 5 return end local RandomSpawn = Spawnpoints[math.random(1, #Spawnpoints)].CFrame + Vector3.new(0, 4.5, 0) repeat Root.CFrame = RandomSpawn wait() until (Root.Position - RandomSpawn.Position).Magnitude < 5 end local function RoundCleanup() for _, Player in pairs(game.Players:GetPlayers()) do Player:LoadCharacter() end end local function StartRound() InRound.Value = true for _, Player in pairs(game.Players:GetPlayers()) do Player:LoadCharacter() end for i = RoundLength, 0, -1 do wait(1) Status.Value = "Game - "..i.." seconds left!" end InRound.Value = false RoundCleanup() if InRound then local Humanoid = Character:WaitForChild("Humanoid") end end local function StartIntermission() for i = IntermissionLength, 0, -1 do wait(1) Status.Value = "Intermission - "..i.." seconds left!" end StartRound() StartIntermission() end game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if InRound.Value then SpawnPlayer(Character) else SpawnPlayer(Character, Lobby) end local Humanoid = Character:WaitForChild("Humanoid") Humanoid.Died:Connect(function() wait(RespawnTime) Player:LoadCharacter() end) end) end) StartIntermission()
Thanks.