I think its the way variables are stored, like youre editing a variable with itself if you know what I mean, try with another variable then cross compare
I see. Well, I wonder if the issue is related with print() itself?
local TestVar = false
local String = "Test A "
TestVar = String:gsub("%s+$", "") -- Editing the string and storing it
print("'Live' editing:", String:gsub("%s+$", "")) -- Directly printing a "live" string edition
print("PreEdited:", TestVar) -- Printing the stored one
The first code prints the return values of String:gsub i.e. “Test A” and the number of substitutions made i.e. “1”.
The second code prints the value of String2, which you have just changed to be the amended string result of String:gsub(“%s+$”, “”)