Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Solved] Why do i get Attempt to index number with 'reverse'?

addComas function:

local function addComas(str)
	local x = tostring(str)
	return x % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse()
end

the part of the script that's making the error?:

TIP:WaitForChild("ItemInfo").Text = addComas(_MOD.MinDamage) .. "-" .. addComas(_MOD.MaxDamage) .. " DMG / CD: " .. addComas(_MOD.Cooldown)

I suck at coding so I have no idea what's going on any help is appreciated thank you!

1 answer

I got the solution

I had to replace the str:reverse stuff with x:reverse I'm dumb

Heres the fixed code if anyone is wondering:

local function addComas(str)
	local x = tostring(str)
	return x % 3 == 0 and tostring(str):reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or tostring(str):reverse():gsub("(%d%d%d)", "%1,"):reverse()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.