Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Could someone help me with this Map Changing script?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So I've been making a Game Engine that just gets the players in the game to spawn in a randomly chosen map. That part finally works. Now I'm trying to figure out a way so that when people die they spawn at the game if the game is still going on. I did attempt by making that SpawnLocation1 in my game Disabled.That was only the first step...

Script Below:

minigames = game.ServerStorage.Minigames:GetChildren()

    h = Instance.new("Hint", game.Workspace)

    while true do
        if game.Players.NumPlayers > 0 then 
            h.Text = "Deciding what game to play"
            wait(3)
            ranGame = math.random(1, #minigames)
            gameChosen = minigames[ranGame]
            h.Text = gameChosen.Name
            wait(3)
            gameChosenClone = gameChosen:Clone()
            gameChosenClone.Parent = game.Workspace
            wait(3)
            spawns = gameChosenClone.Spawns:GetChildren()
            --Players spawn
                for i,v in pairs(game.Players:GetPlayers()) do 
                --Player check
                name = v.Name
                --Disables SpawnLocation
                game.Workspace.SpawnLocation1.Enabled = false
                check = game.Workspace:FindFirstChild(name)
                --Checks if checked
                    if check then 
                    checkHumanoid = check:FindFirstChild("Humanoid")
            end

                    if checkHumanoid then
                    check:MoveTo(spawns[i].Position)
                    end
            end
            for i = 3, 1, -1 do 
                h.Text = "Game begins in:" .. i
                wait(1)
            end

            --Game countdown
            for i = 60, 1, -1 do 
                wait(1)
                h.Text = "Time left: " .. i
                wait(1)

            end
            gameChosenClone:Destroy()
            h.Text = "Game ended!"
            wait(1)
            game.Workspace.SpawnLocation1.Enabled = true
        else
            h.Text = "There needs to be one than 1 character to start bro!"

        end
    wait(1)
    end

Answer this question