✓ Accepted answer
You can compare two strings without case by using the lower or upper method on both of them.
print(("bob"):lower() == ("BOB"):lower())
To create a method.
In regular Lua you could modify string
string.equalsIgnoreCase = function(self,other)
return self:lower() == other:lower()
end
print(("Hello"):equalsIgnoreCase("HELLO"))
Since Rbx.Lua doesn't allow modifications to string.
The closest you will get to this in Rbx.Lua is:
local NewString = {}
for o,n in pairs(string) do
NewString[o] = n
end
local E = getfenv()
E.string = NewString
setfenv(1,E)
string.equalsIgnoreCase = function(one,two)
return one:lower() == two:lower()
end
print(string.equalsIgnoreCase("BOB","bob"))
Or just a function
equalsIgnoreCase = function(one,two)
return one:lower() == two:lower()
end
print(equalsIgnoreCase("BOB","bob"))