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

My roblox Rounds Table is not working which takes away players on death?

Asked by 6 years ago

i made this script here which is supposed to Add a Player at the start of the round and then change the value to who survived at the End!

local list = {}
local D = game.ReplicatedStorage:WaitForChild("Status")
while true do
    wait(1)
for i, player in ipairs(game.Players:GetChildren()) do
table.insert(list, ""..i.."")
wait(10)
D = ""..list[i].." Survived"
wait(99999)
end end

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            table.remove(list,player.Name)
        end)
    end)
end)

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago

Create a script that adds a StringValue to the Player.

game:GetService('Players').PlayerAdded:connect(function(player)
    local stringvalue = Instance.new("StringValue")
    stringvalue.Name = "Status"
    stringvalue.Parent = player
    stringvalue.Value = "Alive"
end)

You can change the Status value to "isDead" or "Dead" when the player dies (Humanoid.Died:connect(function()) and when the round ends, check all of thee players Status value if it is "Dead" or "Alive"

for _, v in pairs(game.Players:GetChildren()) do 
    if v:FindFirstChild("Status") then 
        local player = v
        local plrstatus = player:FindFirstChild("Status")

        if plrstatus.Value == "Alive" then 
            print("" .. player.Name .. " survived!")

        elseif plrstatus.Value == "Dead" then 
            print("" .. player.Name .. " died!")
        end
    end
end
Ad

Answer this question