Can you TP a player when they say a word without needing /e?

I’ve been using a /e [WORD] type of script to teleport a player to different games and places. I wanted to know if there is any easier way to teleport a player without using /e, possibly whenever they say a specific word in a certain area. I’ve been trying to get stuff done with CFrames, but I ended up deleting it all. Does anyone have any ideas?

3 Likes

You have the option to utilize the Player.Chatted event and verify if the player’s message matches your specific keyword. For further information, I have included a link to its documentation that you can explore.

4 Likes

You can create a part and use the function onTouched(), and also Player.Chatted to create something like this, it’s not that difficult, and I could even provide an example code, but that’s the way to do it.

4 Likes

This script is intended to be used by the server.

local Players = game:GetService("Players")

local prefix = "/"

local CommandCases = {
	teleport = function(player: Player, args: { string })
		-- handle the command however
	end,
}

local function RunCommand(command: string, player: Player, args: { string }?)
	local case = CommandCases[command]
	case(player, args)
end

-- Ensures messages are actually commands, then sends them to RunCommand for handling
local function ProcessMessage(player: Player, message: string)
	local cmd, endpos = message:lower():match(`^{prefix}(%a+)()`)

	if cmd and CommandCases[cmd] then
		local args = message:sub(endpos + 1):split(" ")
		RunCommand(cmd, player, args)
	end
end

local function SetupListener(player: Player)
	player.Chatted:Connect(function(message)
		ProcessMessage(player, message)
	end)
end

Players.PlayerAdded:Connect(SetupListener)
2 Likes