For this issue, i want to check when the player chats, 1. If the command is used first. and 2. What is the varible they are specifying.
The main problem with this, is when i do this, the output will just print the table ID and won’t go any futher. Also, if i just check if they used the command, it will fail + stop if i say anything else with it. “!Spawn Cheeseburger” (Will fail)
I’ve tried using str:split(" "), but this will still only check for str[1] and will ignore str[2]
P.Chatted:Connect(function(c)
local SimplifiedChat = c:split(" ")
print(SimplifiedChat)
. . .
if SimplifiedChat[1] == TCmds["TowerSpawn"] and SimplifiedChat[2] == table.find(TNames, SimplifiedChat[2]) then
local Players = game:GetService("Players")
local function onPlayerChatted(playerChatType, sender, message, recipient)
print(sender.Name, "-", message, "-", playerChatType, "-", (recipient or "All"))
end
Players.PlayerChatted:Connect(onPlayerChatted)
Have you tried debugging? Use ipairs, loop through the table of strings and see what’s wrong. Maybe it’s not :split that doesn’t work, but the checks you do in the next lines.