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

How would you begin this?

Asked by
IcyEvil 260 Moderation Voter
10 years ago

Im needing a script to where there is a time limit and if it reaches the time limit the get respawned, or if everyone but one person lives they get teleported, or if a person kills all of the players they win etc...

Basically all the murder Games lol, But I need that script and Have no Idea where to start.

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Here's a rough sketch of how it might look:

roundLength = 60

function getPlayersAlive()
    -- Look through all the players who aren't in a lobby and check if they
    -- are on the right team, etc,
    -- returning a list of players
end

function roundFindWinner()
    local startTime = tick() -- Current time
    while tick() - startTime < roundLength do
        wait(1)
        local peopleAlive = getPlayersAlive()
        if #peopleAlive == 1 then
            -- Last person standing.
            -- Different lists for different teams and checking that
            -- one of the lists is empty would work, too, depending
            -- on the rules of the game.
            return peopleAlive[1].Name
        elseif #peopleAlive == 0 then
            -- No one is left playing, so there was no winner
            return "none"
        end
    end
    -- Out of time.
    return "none"
end

while true do
    wait(5) -- Time between rounds
    local winner = roundFindWinner()
    if winner ~= "none" then
        -- `winner` is name of player who won!
    else
        -- no one won (out of time or no survivors)
    end
end
0
Thanks, If I have Any Trouble with this script Mind Helping me? Im Not the Best With Scripting, Im Ok I can Do stuff to keep me treading water, But Just barely. IcyEvil 260 — 10y
Ad

Answer this question