Hello there the users of devforum. I’ve come across an error in my script where using this Or condition doesn’t work. Though it works I have a bunch of other tools in my game that can somehow open this even when its not in this code. Ideas?
if hit.Parent.Name == "Keycard" or "LI Keycard" or "LV Keycard" or "LX Keycard" or "LO Keycard" then
When you use Or you need to specify the conditions your trying to compare against, it wont try to compare the first condition to the rest of the or statements.
if hit.Parent.Name == “Keycard” or hit.Parent.Name == “LI Keycard” or hit.Parent.Name== “LV Keycard” or hit.Parent.Name == “LX Keycard” or hit.Parent.Name== “LO Keycard” then
That’s also kinda inefficient. You’re using table.find with array-like tables even though you don’t need the indices. You should use table indexing with dictionary-like tables as that wouldn’t traverse the entire array to check if some string is in.
local acceptableOpeners = {
["Keycard"] = true,
["L1 Keycard"] = true,
["LV Keycard"] = true,
["LX Keycard"] = true,
["LO Keycard"] = true
}
if acceptableOpeners[hit.Parent.Name] then
print("object found")
end