1 | SecTime = game.workspace:GetAttribute( "Second" ) |
2 | while true do |
3 | wait( 1 ) |
4 | SecTime = SecTime + 1 |
5 | game.Workspace:SetAttribute( "Second" , SecTime) |
6 | end |
It gives me a error, attempting to do arithmetic at line 4. How do i fix it
Hello!
You see, strings can not be added, subtracted, multiplied, whatever, with a number. What you can do, is to first convert the string to a number, and then convert it back to a string.
1 | local string = "200" |
2 |
3 | local finalnumber = tonumber (string) + 300 |
4 |
5 | local finalstring = tostring (finalnumber) |
If you're confused, you can go here for an article about strings and their behavior.
I hope this helps!
your code was much deprecation
1 | local start = os.time() |
2 |
3 | while true do |
4 | local now = os.time() |
5 | workspace:SetAttribute( "Second" , math.floor(now - start)) |
6 | wait( 0.5 ) |
7 | end |