✓ Accepted answer
The error you're getting is because you're providing the table itself instead of any of the contents inside. You'd need to iterate through the table using a for loop and check if the player's message contains any of those values.
local ScareEnablers = {
";enable scary mode";
";enable scary";
";enable scares";
";scares enabled";
";scares on";
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
for index, value in pairs(ScareEnablers) do
if msg:lower():find(value) then
local char = plr.Character or plr.CharacterAdded:Connect()
local hum = char:FindFirstChild("Humanoid")
hum.WalkSpeed = 9
print("Working")
break
end
end
end)
end)
Another way of doing this is by using table.find which will check if the given element is inside the specified table. This will return the index position of the element that is inside the table or, it will return nil if it cannot find the element inside the table. You can see more about table.find here (scroll down to the bottom)
local ScareEnablers = {
";enable scary mode";
";enable scary";
";enable scares";
";scares enabled";
";scares on";
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if table.find(ScareEnablers, msg:lower()) then
local char = plr.Character or plr.CharacterAdded:Connect()
local hum = char:FindFirstChild("Humanoid")
hum.WalkSpeed = 9
print("Working.\nIndex Position:",table.find(ScareEnablers, msg:lower()))
end
end)
end)