Weird behaviour by print

  1. What do you want to achieve?

Remove the weird behavior by print

  1. What is the issue?

Screenshot 2023-09-13 212213

It prints a number 1, I don’t know how and why it prints 1 and I believe none of my code does or manipulate this. This affect other prints, almost everytime I use print() at the end of the word it prints 1.

  1. What solutions have you tried so far? I am confused.

I tried your initial method to see if it was a bug on your end and I was able to replicate the 1 printing. I’m guessing it has something to do with print logic.

Solution: I honestly couldn’t tell you why, but printing the gsubbed string as a variable seems to work. If anyone knows please let us know :grinning:

local stringTest = [[
test {str}
]]

local newstring = string.gsub(stringTest, "{str}", game.Players.LocalPlayer.DisplayName)
print(newstring)

Result:
image

1 Like

Look to the documentation of string.gsub() it returns string and number
if you do not want that 1 at the end consider using string.format(Str: string, …)
or use the method @PR_0B listed above

3 Likes

Okay, I will try to put it in a variable…

Alright It does work with a variable, but it seems more reliable to use string.format as @s1mple66645 said. Thanks to both of you!

1 Like

1 Like

alternative solution:

print(select(1,string.gsub([[


]])))
1 Like

uh kinda ugly solution, who cares about select func???

shhhhhhhhhh

I use select and my code is ugly and i dont even think about it much xddd

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.