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

string.format does not work with player.Name?

Asked by 7 years ago
Edited 7 years ago

I am so confused right now you like don't understand.

I created this string.format script and it is coming up with an error on line 2;

bad argument #2 to 'format' (string expected, got no value)

The script;

print(player.Name) -- THIS DOES HAVE A VALUE! IT IS NOT NIL!!
output(string.format('%s has done the event thing'), tostring(player.Name))

Any help would be greatly appreciated!!!

EDIT: This works completely fine;

output(player.Name..' has done the event thing')
0
Does '%s has done the event thing':format(player.Name) Work? Omarstein 100 — 7y
0
@Omarstein no, that does not work. WelpNathan 307 — 7y

1 answer

Log in to vote
0
Answered by
Versimn 20
7 years ago
Edited 7 years ago

I don't really know anything about string formatting, but I got it working with the wiki

print(player.Name) -- THIS DOES HAVE A VALUE! IT IS NOT NIL!!
output(('%s has done the event thing'):format(player.Name))
0
Came up with the error of 'attempt to index a nil value' WelpNathan 307 — 7y
Ad

Answer this question