Alright, the title was a little confusing but basically I’m making a trading system.
The script for sending the request will work if the player says
"!Trade "..[Player you wish to trade with]
My problem is that I need to check if the player said another player’s name.
I have a table called players and every time someone joins it’ll add their name to that table
I want to make it so it checks all the values of that table and if the name the player said is in that table it’ll continue the script
local players = {
}
game.Players.PlayerAdded:Connect(function(player)
table.insert(players, player.Name)
player.Chatted:Connect(function(msg)
if msg == "!Trade ".. then
end
end)
end)
If that doesn’t make sense please reply asking for more clarification.
TLDR: I’m trying to figure out how to make an if statement checking if the player says something and that message is part of a table
local players = {}
game.Players.PlayerAdded:Connect(function(Player)
if not table.find(players,Player.Name) then
table.insert(players,Player.Name)
end
Player.Chatted:Connect(function(Message)
for _,plr in pairs(players) do
if plr ~= Player.Name then
if Message:match(plr) then
print(Player.Name.."sent trade request to -"..Message:match(plr))
end
else
warn("Cant trade yourself!")
end
end
end)
end)