Why do my custom commands not work (Teleport and other)

My script:

local commands = {}

local prefix = ":"

local function findPlayer(name)

	for i, player in pairs(game.Players:GetPlayers()) do 
		if string.lower(player.Name) == name then
			return player


	return nil 


commands.tp = function(sender, arguments)

	print("TP Fuction fired by "..sender.Name)

	for i, playername in pairs(arguments) do 

	local playerToTeleportName = arguments[1]
	local playerToTeleportToName = arguments[2]

	if playerToTeleportName and playerToTeleportToName then 
		local plrToTP = findPlayer(playerToTeleportName)
		local plrToTPTo = findPlayer(playerToTeleportToName)

		if plrToTP and plrToTPTo then 
			plrToTP.Character.HumanoidRootPart.Cframe = plrToTPTo.Character.HumanoidRootPart.Cframe
			print("Successfully moved!")


	if player:IsInGroup(8972210) then

	player.Chatted:Connect(function(message, recipient)
		message = string.lower(message)

		local splitString = message:split(" ")

		local slashCommand = splitString[1]

		local cmd = slashCommand:split(prefix)

		local cmdName = cmd[2]

		if commands[cmdName] then 

			local arguments = {}

			for i = 2, #splitString, 1 do

			commands[cmdName](player, arguments)



Hello & welcome to the community, do you have any errors in the output?

What do u mean? Pls help.

Output | Roblox Creator Documentation Here you go, remember to research before asking! :mag:

No i dont have any errors

Can you send a screenshot of output once you’ve ran the command?

It also looks like your script has a few issues, e.g:

Doesn’t do anything, removing it will keep your code clean.

But i want that bcs Youn only can use if ypu’re in the group

Use GroupService, I believe players:isingroup Is deprecated.

Player.IsInGroup should still be working. It’s mentioned in Group Service & should still be working just fine.

GroupService is just a waste of time & code lines. IsInGroup works fine.

if plr:IsInGroup then

That will work just fine, correct?

Is that good? so

if plr:IsInGroup 12345 then


You would want a Variable like this:

local GroupId = nil -- Change to your group ID

And then a function within your script like this:

if plr:IsInGroup(GroupId) then

If you need anymore help, be sure to come back here!

Thank you for help! I put more charachters bcs i have to put 20+ XD

1 Like

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