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

How can I convert a table with player names into string value?

Asked by 4 years ago

I have no code because I have no idea where to even begin-

I have a string value named "winners" which should hold all of the player names in the table, and a table that holds player names.

How do I put ALL of the player names into the string value- rather than just one?

0
concatenate everything into a single string then match the string if you want to access it DiamondComplex 285 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

You can use string table.concat(table<string> strings [, string seperator = "", string start = 1, string end = #]) which will take a table that only contains strings e.g. {"Logophilic", "SynthetickDev"} and you can then give it a seperator that it will put between each string within the table. You can also specify a start index and an end index which tells it what strings to concatenate. It will then return a string value of the concatenated strings.

Example code:

local Players = {"Logophilic", "SynthetickDev"}

print(table.concat(Players, " and ")) -- Output: Logophilic and SynthetickDev

Hope this helps!

Ad
Log in to vote
0
Answered by 4 years ago

You can do something like this

local table = {

for i,Player in pairs(game.Players:GetPlayers()) do
    if Player.folder.WinnerValue == true then
    "Player,"..Player.Name.. -- something that would put it to the table
                    --idk how u want to do it but you basically get the players name and if u want you can print it or something
end

}

Answer this question