Hello everyone, I have such a problem in the script that it gives such an error, I don’t know what to do. the script runs every other time. I hope for your help!
local modulScript = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))
local randomGold = modulScript.randomGold
local gui = script.Parent.Parent
local text123 = gui:WaitForChild("TextLabel1")
text123.Text = randomGold
local function changeGems()
local abbreviations = {
K = 4,
M = 7,
B = 10
}
local text = tostring(math.floor(randomGold))
local chosenAbbreviation
for abbreviation, digits in pairs(abbreviations) do
if #text >= digits and #text < (digits + 3) then
chosenAbbreviation = abbreviation
end
end
if chosenAbbreviation then
local digits = abbreviations[chosenAbbreviation]
local rounded = math.floor(randomGold / 10 ^ (digits - 2)) * 10 ^ (digits - 2)
text123.Text = string.format("%.1f", rounded / 10 ^ (digits - 1)) .. chosenAbbreviation
else
text123.Text = text
end
end
changeGems()
local module = {
randomGold = math.random(200000, 250000),
randomGem = math.random(2, 10)
}
return module