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

How do i name all players without one at a time?

I'm trying to make it so it tells the players name an i want it like this "Winners: UltraUnitMode, Guest666, ROBLOX" if you know what i mean, so far i can only do it one at a time so it goes like this "Winners: UltraUnitMode" waits a second "Winners: Guest666" so on, hence the wait. Also I'm not sure if tostring() is a good idea to make it do that? Idk so thats why im asking lol

function LookForWinner()
local Players = game.Players:GetChildren()
for i = 1, #Players do
if Players[i]:FindFirstChild('leaderstats') then
if Players[i].leaderstats.KOs.Value >= 25 then
Message('Winners: '..Players[i].Name) -- Sends into the function and changes the text for everyone
wait(1)
end
end
end
end

1 comment

0

That's one heck of a run-on sentence. And no, you would have to use a Loop to get and rename all the players.

1 answer

✓ Accepted answer

Since you're not dealing with a Table, you have to use string concatenation in a loop:

function LookForWinner()
	local winners = ""

	for _, player in ipairs(game.Players:GetChildren()) do
		if player:FindFirstChild('leaderstats') and player.leaderstats.KOs.Value >= 25 then
			winners = winners .. (#winners > 0 and ", " or "") .. player.Name
		end
	end

	Message('Winners: ' .. winners)
	wait(1)
end

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