Trading system help

so me and my friends are developing a game and we want a trading system. so basically how do we check if someone said the word “?trade” before a players name (we get the players name by saving it in a variable then looping through the playersservice children)?

example:

“?trade ekuz0diaa”, how do we check if they said “?trade” before “ekuz0diaa”

You can use string.split and check if the first entry is “?trade”

Adding on to what @NachtHemd mentioned…

Using the Chatted Event, you can check the input made by a player and split their message into arguements.

Example:

game.Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:Connect(function(msg)
        local message = string.lower(msg) -- Makes for easier checks
        local args = string.split(message, " ") -- Each word would be separated by a space so theoretically speaking, you can assume they say ?trade user

        if args[1] == "?trade" then
                -- Your Code here
        end
    end)
end)

Hope this helps!

1 Like