Hello!
I am trying to have a script detect when there’s a sale, the issue is that I use numbers that aren’t easily rounded which causes lots of decimals to appear. While it technically isn’t correct, it’s not appealing. Is there a way to easily solve this without adjusting my prices?
I’ve looked it up and Lua doesn’t have a math.round feature so that isn’t an option unfortunately.
Here’s my script and the result:
local MPS = game:GetService("MarketplaceService")
local Gamepasses = {
["VIP"] = {
["GamepassID"] = 10587779,
["DefaultPrice"] = 199
},
["Double"] = {
["GamepassID"] = 10587903,
["DefaultPrice"] = 99
}
}
while true do
for i,v in pairs(Gamepasses) do
local price = MPS:GetProductInfo(v.GamepassID, Enum.InfoType.GamePass).PriceInRobux
for i2,v2 in pairs(script.Parent.Gamepasses[i]:GetDescendants()) do
if v2.Name == "Price" and v2:IsA("TextLabel") then
v2.Text = "R$"..price
if price <= v.DefaultPrice then
local sale = script.Parent.Gamepasses[i].SaleLabel
sale.Visible = true
sale.Text = (1 - (price / v.DefaultPrice)) * 100 .."% OFF!"
end
end
end
end
wait(300)
end