Hello, I was working with decimal calculations in scripting, and I encountered a strange issue. For example, 40.2 turned into 40.3000…4. Is this a bug?
local Acc = script.Parent.Parent.Parent.Parent.Acc
script.Parent.MouseButton1Click:Connect(function()
if Acc.Value == 1 then
else
Acc.Value += 0.1
end
end)
and the code for subtracting is:
local Acc = script.Parent.Parent.Parent.Parent.Acc
script.Parent.MouseButton1Click:Connect(function()
if Acc.Value == 0 then
else
Acc.Value -= 0.1
end
end)
The initial value is 40. However, each time those buttons are pressed, the value increases or decreases by 0.1.
It keeps adding, and then an unknown bug occurs.
so, Im assuming your Value is a NumberValue, well computers rlly have a strange behavior sometimes, such as that thing.
local Acc = script.Parent.Parent.Parent.Parent.Acc
script.Parent.MouseButton1Click:Connect(function()
if Acc.Value == 1 then
else
Acc.Value += 0.1
Acc.Value = tonumber(string.format("%.1f", Acc.Value))
end
end)
maybe try this, it rounds the number to decimals since its a float