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

What function to delete a last digit from a value ?

I want a script function to delete last digit from an value. Just one last in the text string or numbervalue. I'm not sure what functions i need to make smth like that. It's hard to find anything in developer.roblox.com I use as main function MouseButton1Click cause it will run when clicked a button.

script.Parent.MouseButton1Click:connect(function(buy)  --[[C clear and save]]
	local mem = script.Parent.Parent.Parent.HDDMEM
	local butt = script.Parent.Parent.Parent.Memory.Buttons
	-[[there i need that function]]
	
	wait(0.01)
	
end)

Thanks for every help. /EDIT "Are you trying to remove a digit itself or just -1 from the value?" Read my questions once again until you get it.

9 comments

0

use :Connect(), :connect() is deprecated

0

Are you trying to remove a digit itself or just -1 from the value?

0

In order to remove last the last digit from a value, do this: local val = 15; val = math.floor(val / 10)

1

It doesn't work SaltyIceberg but i may not understand what you want to tell me. I'm gonna learn using this math.floor function but it's hard without working script that use this function.

1

If the value is a string, then this may help https://developer.roblox.com/en-us/api-reference/lua-docs/string. If you don't understand it well, search for tutorials related to strings.

0

Also, if it's a number, use "tostring()" to make the number a string, remove last digit, use "tonumber()" and there you go.

1

you can use this for numbers math.floor(Value/10)*10 or this for strings string.sub(1,#Text-1)

0

IDK I wrote a comment a second time and, it didn't show on the question page. What's wrong with your scripting helpers

0

Whatever. Seems I already did what did I want. So thanks.

1 answer

✓ Accepted answer

gsub and/or other string library functions.

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