My code instead of adding by 0.05 or removing its causing stuff to go weird
manage.ClickDetector.MouseClick:Connect(function(plr)
if plr.Team.Name == "King" then
stand.Pay.Value = stand.Pay.Value + 0.05
Messager.Notify(plr, "Raised the pay to " .. tostring(stand.Pay.Value), Color3.new(0,0,0))
else
Messager.Notify(plr, "YOU NEED TO BE KING TO DO THIS", Color3.new(0,0,0))
end
end)
manage.ClickDetector.RightMouseClick:Connect(function(plr)
if plr.Team.Name == "King" then
if stand.Pay.Value ~= 0 then
stand.Pay.Value = stand.Pay.Value - 0.05
Messager.Notify(plr, "Lowered the pay to " .. tostring(stand.Pay.Value), Color3.new(0,0,0))
else
Messager.Notify(plr, "IT CANT GO UNDER 0", Color3.new(0,0,0))
end
else
Messager.Notify(plr, "YOU NEED TO BE KING TO DO THIS", Color3.new(0,0,0))
end
end)
That’s actually normal for floating point types. The IEEE 734 standard has the breakout of the machine word (32-bit or 64-bit) floating point numbers. The issue is the mantessa itself. The most significant bit, when set, adds 0.5 to the value, then the next bit is 0.25, next is 0.125, and so on. It’s because 0.05 cannot be represented exactly by power of 2 floating point representation. Your best bet would be to do this:
This shifts the decimal point two places to the right, subtracts 5, then shifts it back 2 places to the left. If you are looking to display it, then do this:
To be honest, @nicemike40 has a better solution for displaying it. If you are familiar with C at all, string.format is basically like sprintf in C. But for the format, I would use “%0.2f” instead because if the value goes less than 1, it will print a leading 0 before the decimal point.
You can read more about string.format here in the Roblox documentation.
Yeah, I forgot about string.format even though I used it myself. I updated my answer to reflect that the OP should use your solution to display, with a modification.