How to squish numbers together without adding them?

So I am trying to set a value for a number value. I have 3 numbers in my script but I don’t know how to put them together. I don’t want to add them but put them side by side.

Imagine my numbers were 1, 2, 3. I want to make it 123. But I want to add a dot like this, “1.23” to make one number and set it as the value for the number value.

Any ideas on how I might be able to achieve this problem?

Well if it’s always three numbers, you could just
tonumber(tostring(num1).."."..tostring(num2)..tostring(num3))

It’s not the prettiest solution, but it is a solution nonetheless. You could generalize it to work with a table of numbers and a specific number of digits to place the decimal point after if you need that as well.

3 Likes

I have already tried that but it doesn’t change the value in the properties tab. That’s the value I want to change.

ValueObject.Value = tonumber(num1.. num2.. num3)?

btw you don’t need to use tostring here

what do you currently have in your script?

should work

local maxtime = 10
local seconds = 0
local decisecond = 0
local centisecond = 0
local stopwatch = script.Parent
local button = script.Parent.Parent.StartButton
local score = stopwatch.Parent.Score

repeat
stopwatch.Text = tostring(seconds)…"."…tostring(decisecond)…tostring(centisecond)
wait()
centisecond += 3

if centisecond >= 10 then
decisecond += 1
centisecond -= 10
end

if decisecond >= 10 then
seconds += 1
decisecond -= 10
end

score.Value = tostring(seconds)…"."…tostring(decisecond)…tostring(centisecond)

until button.BackgroundColor3 == Color3.new(255, 0, 0) or seconds == maxtime

score.Value = score.Value - .03

print(score.Value)

This is my current script and line #28 is just to remove the delay.

image

When I got to test it out the Value stays at 0 the whole time. I was thinking maybe it has something to do with what type of value I am using because right now I am using a number value.

I am making a stop watch that is activated by a button but I don’t think that matters. This script also gets disabled and undisabled.

That didn’t work for me but you can go check out my current script. It’s further down.

pretty sure this is the problem, you aren’t supposed to concatenate strings with ... but with ..

Oh, I see, it just glitched out when I copy and pasted it in. lol :confused:

I am using … but it glitches when I blockquote it.

Can you mark this post as resolved?

No one has solved it yet. None of the ideas here do what I say.

1 Like
local numbers = {1,2,3,4,5,6,7,8,9,0}

local result = ""

for i,v in pairs(numbers) do
    if i == 1 then
        result = v.."."
    else
        result = result..v
    end
end

result = tonumber(result)

print(result)
1 Like