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

How could I improve this script?

Asked by 9 years ago

I'm making an free-for-all round for a FPS game. In my script, when there is only one player left standing, that player is awarded 100 Cash (Player.leaderstats.cash), but if 3 minutes (180 seconds) go by and there are more than one players still alive, they are all killed and no Cash is awarded.

  function ffa()
                    local countdown = coroutine.wrap(function()
                    local timer = 180
                    while wait(1) do
                    timer = timer - 1
                    if timer == 0 then
                    if #Players >= 1 then
                    for i, v in pairs(Players) do
                    local char = v.Character or repeat wait() until v.Character
                    local hum = v.Humanoid or repeat wait() until v.Humanoid
                    hum:TakeDamage(100)
                    elseif #Players == 1 and timer > 0 then
                    hum:TakeDamage(100)
                    Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 100
                    end
                    end
                    end
                    end
    end

On line 9, I get the following error: "Expected identifier, got "repeat"'

I tested it and it does not work. Thanks for your help.

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

A repeat loop does not yield a value, only function calls and indexes return a value. Move repeat wait() until v.Character one line up and replace the next line with local hum = char:WaitForChild("Humanoid")

Ad

Answer this question