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

How can I fix this script so that it outputs multiple player names in hint?

Asked by 9 years ago
function ToolCheck()
    wait(1)
    local Check = game.Players:GetChildren()
    for _,v in pairs(Check) do
        local found = false
        local BKP = v.Backpack:GetChildren()
        for __,x in pairs(BKP) do
            if x.Name == "AK47" then
                found = true
            end
        end
        if found == false then
            A.Text = v.Name.. " has got none."
        end
    end
end

I want the output into hint as this: "Player1, Player2, Player3, Player4, Player 5 has got none."

The question is...how?

1 answer

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

The simplest way is to keep a list of all of the names you want to put out instead of just outputting any single name:

local nameList = {};

... -- Your loops

    if not found then
        -- instead of == false. Easier to read
        table.insert(nameList,v.Name);
        A.Text = table.concat(nameList,", ") .. " has got none";
    end
-- The remainder of your stuff
Ad

Answer this question