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

How would I be able to compare strings?

Asked by 4 years ago
Edited 4 years ago

For example

local number = 30

if number >= 30 then
print("Not")
end

^ That's how I would compare numbers, but how would I compare strings?

Solved

I can compare strings by

local string1 = "hello"
if string1 == "hello" then
print("Hello World!")
end

1 answer

Log in to vote
1
Answered by 4 years ago

Just as you can compare two numbers to see if they're equal, you can compare two strings to see if they're the same.

print("string1" == "string2") --Will be false
print("string" == "string") --Will be true

There's a bunch of other, more advanced, ways of comparing strings using functions from the string library.

Ad

Answer this question