Follow the tutorial here.
local TeleportService = game:GetService("TeleportService")
local GameId = 6872265039 --Set this gameId to what game you want to teleport to.
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(Msg)
if Msg == "/BedWars" then --Customize command.
TeleportService:Teleport(GameId, player)
end
end)
end)