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

How do I make a script that counts the amount of digits in a value? [closed]

Asked by
Mpire_z -2
4 years ago

I want to make a keypad code, so how do I reset the code it the amount of digits in the value is > than 3?

0
We'll need a tad more to work on. fredfishy 833 — 4y
0
Learn strings. User#27525 1 — 4y

Closed as Non-Descriptive by fredfishy, MageMasterHD, and Leamir

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
U_srname 152
4 years ago

How many digits?

Well, you need to use string.len

If the value is only digits, then you can get the length of the value, which will tell you how many digits there are.

Here's an example:

local Number = 73948329

local Digits = string.len(tostring(Number))

print(Digits)
0
example2: local bit = "Billy bob broke bob's billy bike." print(#bit) ryan32t 306 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

I'm not a 100% sure on if this works, but try this:

local value = script.Parent.Digits.Value
if #value > 3 then
    print("Your code here")
end