Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to auto respond back to certain player on chat?

Asked by
TechModel 118
2 years ago
Edited 2 years ago

I want to make so a specific player ID for example 12345 and when that player in the game says "Hi" the rest of the server who has enabled this script will reply in the chat will reply, "Hey!" back in the default chat system of Roblox.

So, I did some coding and got a bit lost. Hopefully you guys can help. I have searched on Roblox forum but it got confused. I was hoping a code to be simpler and asking if anyone can help simplify this. Thanks!

local Perms = {
    12345
}

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for _, i in ipairs(Perms) do
            if player.UserId == i then
                if msg:sub(1, 3):lower() == "/oi" then
                    local text = msg:sub(5, #msg)
                    game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer("text", "All")
                end
            end
        end
    end)
end)

Answer this question