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.
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
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.
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.
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)