How to make it so that if a person chats something specific they get teleported to another experience?

Basically, I want to make a script where if a player says something specific in chat, that specific player only (who said the specific message in chat) will be teleported to another game. I also wanted to make it so that it doesn’t show in chat for others when someone says it, because it’s more of a secret code. How do I make all of that?

string.find() finds a string pattern in the string thats given to

-- get the player
player.Chatted:Connect(function(message)
	if string.find(message, "INSERTTELEPORTMESSAGE") then
		-- code, use TeleportService
	end
end)
1 Like

I’m not sure if this is still correct because I don’t use studio but the last time i checked you can’t hide messages without using the old chat

1 Like

Server script:


local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local secretCode = "Teleportme" --  change this

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if message:lower() == secretCode:lower() then
            local placeIdToTeleport = "PlaceIDHere" -- change this
            local success, errorMessage = pcall(function()
                TeleportService:Teleport(placeIdToTeleport, player)
            end)

            if not success then
                warn("Teleportation failed:", errorMessage)
            end
        end
    end)
end)
  1. Replace “Teleportme” with your specific phrase: Replace the "Teleportme" variable with the actual phrase that you want players to say.
  2. Replace “PlaceIDHere” with the target place ID: Replace "PlaceIDHere" with the actual PlaceID of the game you want to teleport players to.
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.