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

How to make a script continuously check?[unanswered]

Asked by
wjs3456 90
10 years ago

I have this script here that I am using to "end the round." (Checks if the team "Survivors" has zero people) The problem is that it runs, but after that doesn't continuously check if it is true. I tried to add a while loop , but that doesn't seem to work. So how can I make it check until the statement is true?

function waitforwinner()
while wait() do
if #_G.getTeam(game.Teams.Survivors) == 0 then
        m = Instance.new("Message",Workspace)
            m.Text = "The final survivor was infected. Infected win !Once you respawn the round will begin!"
        wait(3)
    m:Destroy()     
            if first_infected.StarterGear.Revolver ~= nil then
                first_infected.StarterGear.Revolver:Destroy()
                    game.Workspace.Field1.Parent = game.Lighting
                    wait(3)
                    game.Lighting.Field1.Parent = game.Workspace
                    _G.blue()--global function makes everyone blue again
                        if #_G.getTeam(game.Teams.Infected) == 0 then
        begin("The round has begun.",3)
        GiveGun()
        FirstInfected("A player has been randomly infected!",3)
        waitforwinner()
                        end
            end

                        elseif #_G.getTeam(game.Teams.Survivors) >= 1 then-- If time runs out do
                            wait(400)
                            m = Instance.new("Message",Workspace)
            m.Text = "Time has run out. Survivors win!"
        wait(3)
    m:Destroy() 
    end     
            if first_infected.StarterGear.Revolver ~= nil then
                first_infected.StarterGear.Revolver:Destroy()
                end
                    game.Workspace.Field1.Parent = game.Lighting
                    wait(3)
                    game.Lighting.Field1.Parent = game.Workspace
                    _G.blue()
                        if #_G.getTeam(game.Teams.Infected) == 0 then
        begin("The round has begun.",3)
        GiveGun()
        FirstInfected("A player has been randomly infected!",3)
        waitforwinner()
                        end             
end
end
waitforwinner()

Thanks!

P.S. This is in a function

0
I'm sorry this is tabbed and spaced badly. I've been writing as I go. wjs3456 90 — 10y

2 answers

Log in to vote
-1
Answered by 10 years ago

Courntine.wrap.Function()

Ad
Log in to vote
-3
Answered by 10 years ago

you need to put a while true do in there instead of while wait() do, like this :

function example()
gibba =  false
giff = true
while true do --<- c, not while wait() do
print"hello"
elseif gibba = false then print"hey"
end
example()

btw this is an example

Answer this question