Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.