i click the button then the testvalue = 5 then i click it again and its suppose to be testvalue = 5,5
03:20:21.555 - Players.Player.PlayerGui.ScreenGui.LocalScript:5: attempt to perform arithmetic on a string value 03:20:21.556 - Stack Begin 03:20:21.558 - Script 'Players.Player.PlayerGui.ScreenGui.LocalScript', Line 5 03:20:21.559 - Stack End
script.Parent.TEST.MouseButton1Up:connect (function () if script.Parent.testvalue.Value == 0 then script.Parent.testvalue.Value = script.Parent.testvalue.Value + (script.Parent.TEST.Text) else script.Parent.testvalue.Value = script.Parent.testvalue.Value + (","..script.Parent.TEST.Text) end end)
It thinks you are trying to perform math on the string ","
And i dont get what you want to do with it, please explain
You're trying to use +
on a string, ",". Unlike JavaScript, Lua does not use the plus sign for concatenation, so you'll get an error.
Looking at your explanation carefully, I can see that you don't actually add anything to any number. You just want to add a comma, then put the same number there again, 5,5
.
My solution is to not use numbers at all, but to stick with strings, since you don't even need to do any math. Is pseudo code, it would look something like this;
local num = "0" if num == "0" then num = "5" else num = num..", 5" end
script.Parent.TEST.MouseButton1Up:connect (function () if script.Parent.testvalue.Value == 5 then script.Parent.testvalue.Value = script.Parent.testvalue.Value = 5 .. script.Parent.testvalue.Value else script.Parent.testvalue.Value = script.Parent.testvalue.Value + (","..script.Parent.TEST.Text) end end)