I need help with destroying a map

It works but now I have the previous problem lol

Try this, friend

ezgif-5-5abe5266eb

local InGame = game.ReplicatedStorage.InGame
local Status = game.ReplicatedStorage.Status

local LobbySpawn = game.Workspace.Lobby.SpawnLocation
local Maps = game.ServerStorage.Maps:GetChildren()
local ChosenMap = nil
local ChoosenSpawn = nil

local function SetRandomMap()
    ChosenMap = Maps[math.random(1, #Maps)]
    ChoosenSpawn = ChosenMap.SpawnLocation
end

--- Teleport ---

InGame.Changed:Connect(function()
    if InGame.Value == true then
        wait(1)
        for _, player in pairs(game.Players:GetChildren()) do
            local character = player.Character
            character.HumanoidRootPart.CFrame = ChoosenSpawn.CFrame
            ChosenMap:Clone().Parent = workspace
        end
    else 
        wait(1)
        for _, player in pairs(game.Players:GetChildren()) do
            local character = player.Character
            character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
            if ChosenMap then
                 workspace:FindFirstChild(ChosenMap.Name):Destroy()
            end
        end 
    end
end)

--- Intermission and game Timer ---

local function roundTimer()
    while wait() do
        for i = 10, 1, -1 do
            InGame.Value = false
            wait(1)
            Status.Value = "Game starts in:"..i
        end
        SetRandomMap() 
        for i = 10, 1, -1 do
            InGame.Value = true
            wait(1)
            Status.Value = "Time left:"..i
        end
    end
end

spawn(roundTimer)
1 Like

Bro thank you so much you solved it!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.