How do i like switch words in a player's message

Hey! so im trying to make a chat system that switches a player’s word, i already saw this system somewhere and it would be cool if someone taught me how to do it.

For example if i type on the chat “This game is cool”
it will switch to “This experience is cool”

Can anyone help me do this?

Use string.gsub()

local str = "This game is cool"
local new = string.gsub(str, "game", "experience")
print(new)

but how would i implement this to change when the player chats?

Use player.Chatted.

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        -- code here, msg is what they typed
    end)
end)

Ohhhh but then i should like, use return to return the new message or what should i do after?

I don’t believe you’re able to alter a player’s chats, if that’s what you’re asking.

Ohh nevermind, i found a way to change it with ChatService, but thanks for the help!