I have multiple scripts that require suffixes, and I always have to edit each and every single one of them so I decided to use module scripts. The problem is I never used them? Also do module scripts require functions?
Module Script
local module = {} function module:getSuf(suf) local suffixes = { 'k','M','B','T','qd','Qn','sx','Sp','O', 'N','de','Ud','DD','tdD','qdD','QnD','sxD', 'SpD','OcD','NvD','Vgn' } module:getSuf(suffixes) end return module
Script
local rs = game:WaitForChild("ReplicatedStorage") local events = rs:WaitForChild("Events") game.Players.PlayerAdded:connect(function(plr) local module = require(game.ReplicatedStorage.Suffixes) module.getSuf(suf) local leaderstats = plr:WaitForChild("leaderstats") local stats = plr:WaitForChild("stats") local robux = stats.Robux local tix = stats.Tix local robuxstring = leaderstats.Robux local tixstring = leaderstats.Tix robux.Changed:connect(function() for i = #suffixes,1, -1 do if robux.Value >= 10 ^ (i * 3) then robuxstring.Value = math.floor(robux.Value / 10 ^ ((i*3) - 2)) * 0.01 .. suffixes[i] .. "+" break elseif robux.Value <= 10 ^ 3 then robuxstring.Value = math.floor(robux.Value * 100) * 0.01 break end end end) tix.Changed:connect(function() for i = #suffixes,1, -1 do if tix.Value >= 10 ^ (i * 3) then tixstring.Value = math.floor(tix.Value / 10 ^ ((i*3) - 2)) * 0.01 .. suffixes[i] .. "+" break elseif tix.Value <= 10 ^ 3 then tixstring.Value = math.floor(tix.Value * 100) * 0.01 break end end end) end)
Also my studio crashes.
You can just instantly return the suffixes
table value upon require
ing like so:
return { 'k','M','B','T','qd','Qn','sx','Sp','O', 'N','de','Ud','DD','tdD','qdD','QnD','sxD', 'SpD','OcD','NvD','Vgn' }
This means when the module is require
d, it'll just return that array. To use this in your script, you can just do it like so:
local rs = game:WaitForChild("ReplicatedStorage") local events = rs:WaitForChild("Events") game.Players.PlayerAdded:connect(function(plr) local suffixes = require(game.ReplicatedStorage.Suffixes) local leaderstats = plr:WaitForChild("leaderstats") local stats = plr:WaitForChild("stats") local robux = stats.Robux local tix = stats.Tix local robuxstring = leaderstats.Robux local tixstring = leaderstats.Tix robux.Changed:connect(function() for i = #suffixes,1, -1 do if robux.Value >= 10 ^ (i * 3) then robuxstring.Value = math.floor(robux.Value / 10 ^ ((i*3) - 2)) * 0.01 .. suffixes[i] .. "+" break elseif robux.Value <= 10 ^ 3 then robuxstring.Value = math.floor(robux.Value * 100) * 0.01 break end end end) tix.Changed:connect(function() for i = #suffixes,1, -1 do if tix.Value >= 10 ^ (i * 3) then tixstring.Value = math.floor(tix.Value / 10 ^ ((i*3) - 2)) * 0.01 .. suffixes[i] .. "+" break elseif tix.Value <= 10 ^ 3 then tixstring.Value = math.floor(tix.Value * 100) * 0.01 break end end end) end)
Hopefully this solves your problem, if it does, please accept it as the answer, if not let me know by commenting below!