for i,v in pairs(game.Players:GetChildren()) do
print(v)
end
This will print every player in the game, into the F9 console. How would I make it print those names into quotations, instead of this
CoolThing123
ThingCool123
CoolThing321
ThingChool321
It would be like
“CoolThing123”
“ThingCool123”
“CoolThing321”
“ThingChool321”
3 Likes
bjdanh266
(2odin66)
August 25, 2021, 2:17am
#2
use string.format
: print(string.format([[“%s”]],v.Name))
or `print("“"…v…"”")
I couldn’t tell you exactly how (it’s late and frankly im not a very good scripter) but this should be able to help
string (roblox.com)
basically you tell the script to put a " at the start, insert the username in the middle, and put another " at the end.
you should’ve linked the dev wiki post, if someone doesn’t know about string formatting that would make no sense, what’s the point of giving people code if they didn’t learn anything.
They could simply search.
@OP , please use game:GetService('Players'):GetPlayers()
, as doing GetChildren
could also get incorrect Instances.
You could print their Name instead of the Instance itself.
XDify01
(XDify01)
August 25, 2021, 2:25am
#6
print("\""..v.Name.."\"")
The \ in \"
is so that the double quote acts as a part if the string
1 Like
I dont know how string.format works all that well but, the error with the first thing you listed is “attempt to index function with print”
1 Like
deluc_t
(Deluct)
August 25, 2021, 2:27am
#8
for i,v in pairs(game.Players:GetPlayers()) do
print('"'..v.Name..'"')
end
2 Likes
Thank you so much, although it prints it like this “/“CoolThing123”/”, I just need “CoolThing123”.
1 Like
incapaz
(uep)
August 25, 2021, 2:49am
#10
string.format
has a format specifier specifically for this, "%q"
. It will also do any necessary escapes for you.
Try these in the command bar.
="hello"
hello
=string.format("%q", "hello")
"hello"
=string.format("%q", "\"hello\"")
"\"hello\""
1 Like
print""…v.Name…""
This Was All I needed the whole time.
1 Like
deluc_t
(Deluct)
August 25, 2021, 5:41pm
#12
No it doesnt. Plus, you need to use backslash and not forward slash to escape characters.
print""…v.Name…""
works for what i needed