Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What function to delete a last digit from a value ?

Asked by
ErtyPL 129
5 years ago
Edited 5 years ago

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.

0
use :Connect(), :connect() is deprecated KDarren12 705 — 5y
0
Are you trying to remove a digit itself or just -1 from the value? irid_leas 97 — 5y
0
In order to remove last the last digit from a value, do this: local val = 15; val = math.floor(val / 10) SaltyIceberg 81 — 5y
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. ErtyPL 129 — 5y
View all comments (5 more)
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. User#27525 1 — 5y
0
Also, if it's a number, use "tostring()" to make the number a string, remove last digit, use "tonumber()" and there you go. User#27525 1 — 5y
1
you can use this for numbers math.floor(Value/10)*10 or this for strings string.sub(1,#Text-1) RubenKan 3615 — 5y
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 ErtyPL 129 — 3y
0
Whatever. Seems I already did what did I want. So thanks. ErtyPL 129 — 3y

1 answer

Log in to vote
1
Answered by 2 years ago

gsub and/or other string library functions.

Ad

Answer this question