How to return only first 3 characters of string

basically this.

example:
local xAngle = 0.3280940912
i want it to only be 0.32 when i print it.
I dont know how to use string.format or that stuff

Use string.sub
string.sub(xAngle,1,3)

In every programming language, these are referred to as “substrings,” which is why the function is called string.sub. A pretty common thing to search whenever you learn a new language is “python substrings” or “c# substrings” because it’s a really common function.
Just FYI. You’ll probably want to know that, it might be on a programming exam if you ever take one.

1 Like

You’d want to do:

string.format("%.2f", xAngle)

This reduces the number to two decimal places

3 Likes

Or

tonumber(string.format("%.2f", xAngle))
-- if you want the number ^^