Search code examples
luaroblox

Trouble cloning monster


I have been working on this for a while, but I cant seem to get it to work. The point of this code is to spawn a monster after the intermission. The player then gets a certain amount of time to survive before intermission starts again. This should happen over and over again. Strangely, it immediately skips to spawning him and the timer doesnt run. Any ideas?

while true do
    game.Workspace.Monster:Destroy()
    for i = 20, 0, 1 do
        game.StarterGui.ScreenGui2.Frame.TextLabel.Text = "That wasn't strange at all... Oh well back to our tea... ".. i
        wait(1)
    end
    local monster = game.ServerStorage.Enemy:Clone()
    monster.Parent = game.Workspace
    for i = 20, 0, 1 do
        game.StarterGui.ScreenGui2.Frame.TextLabel.Text = "SURVIVE.. ".. i
        wait(1)
    end
    game.Workspace.Monster:Destroy()
    
    
end

Solution

  • You've got a simple mistake : your for-loop never decrements.

    You have

    for i = 20, 0, 1 do
    

    And it should be

    for i = 20, 0, -1 do