How to check if a character in a string is a certain key?

The title says it all, i want to check if a character in a string is a space. For example:

print(string.sub("Space Here", 1, 6))

would return " " but how would i make an if statement to check if it’s a space

All you’d need to do is compare it with == to a string containing a single space:

local char=string.sub("space here",6,6) --get the 6th character
if char==" " then --is it a space?
    --it's a space, do stuff
end
1 Like

I feel so foolish for not thinking of that, thanks for the help!

1 Like