How would I find a certain word within a TextLabel? I’m trying to run a function if the word ‘Elevator’ is found within a TextLabel.
local text = game.Workspace.TestPart.SurfaceGui.TextLabel.Text
newWord = newWord:lower(game.Workspace.TestPart.SurfaceGui.TextLabel.Text)
if newWord:find("elevator") then
print("found in string")
end
You should use string.lower() and string.match() for this. :lower and :find can’t be used on strings, because strings themselves don’t have methods like that. Check those out on the API reference on the devhub.
local text = game.Workspace.TestPart.SurfaceGui.TextLabel.Text
newWord = string.lower(text)
if string.find(newWord, "elevator") then
print("found in string")
end