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

Round ends automatically... Help?

Asked by 11 years ago

Edit:

01alive = {}
02 
03for i,v in pairs(game.Players:GetPlayers()) do
04    if v:FindFirstChild("InGame") then
05        v.InGame.Value = true
06        table.insert(alive, i)
07    end
08end
09 
10 
11for i = 1,120 do
12    if #alive == 1 then
13        for i,v in pairs(game.Players:GetPlayers()) do
14            if v:FindFirstChild("PlayerGui") then
15                v.PlayerGui.timer.Frame.timer.Text = (alive[1] .. "Has won!")
View all 34 lines...

2 answers

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
11 years ago

Your problem is actually in the first block of code you posted:

Change table.insert(alive, i) to table.insert(alive, v).

You're inserting the index of the player in the GetPlayers table, instead of the Player themselves.

Edit 2: Change

1for i,v in pairs(game.Players:GetPlayers()) do
2    if v.InGame.Value == false then
3        table.remove(alive, i)
4    end
5end

To

1for _, v in pairs(game.Players:GetPlayers()) do
2    if v.InGame.Value == false then
3        for i, z in ipairs(alive) do
4            if (not z) or v == z then
5                table.remove(alive, i)
6            end
7        end
8    end
9end
0
Now the round doesn't end. Would I use table.remove(alive, i) to remove the player; or?? systematicaddict 295 — 11y
0
That should be working fine. Have it print #alive to the output to check what it's at when people die. adark 5487 — 11y
0
I get the error "Wrong number of arguments to insert" systematicaddict 295 — 11y
0
Woops, I'm sorry. I answered incorrectly. I edited my answer, try it now. adark 5487 — 11y
View all comments (9 more)
0
Found another bug. Should work now! adark 5487 — 11y
0
The round still ends right when it starts. The InGame value does not bug, if you're wondering. In your second edit did you mean (alive, v)? because you wrote (alive, i). systematicaddict 295 — 11y
0
Is it because I'm still using 'if #alive <1 then' ? systematicaddict 295 — 11y
0
The chunk of code under Edit 2 should work as it is. adark 5487 — 11y
0
Change the 'if #alive' bits to how you had them in the question. adark 5487 — 11y
0
It still ends when it starts. I can edit it to show you what I have so far. systematicaddict 295 — 11y
0
Nevermind, I forgot to add a wait, but now it doesn't end... Is there even a way to fix this? I'm using what you're saying. I will edit my question and put what I have so far. systematicaddict 295 — 11y
0
Can't the table.insert(alive, i) in the first loop to table.insert(alive, v) adark 5487 — 11y
0
It works PERFECT now!!! Thanks so much! I know I might of been a little stupid not knowing how to fix it and you didn't have to take this much time to fix it, but thank you so much! I have asked around 100 people and you actually helped fix it!! thanks so much. systematicaddict 295 — 11y
Ad
Log in to vote
-1
Answered by 11 years ago

Try this in line 02 if #alive < 1 then

1
I clearly stated that that didn't work. I tried it before, and it just ended the round when 1 player died; even if there were 3+ players in the server. systematicaddict 295 — 11y
0
message me on roblox so i can help more littledamian55 0 — 11y

Answer this question