Admin commands not printing

I am making a tp commands script and it isn’t printing what is in the function:

local commands = {}

local prefix = "/"

commands.tp = function()
	print("Hello World")
end

game.Players.PlayerAdded:Connect(function(player)
	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
			commands[cmdName]()
		end
	end)
end)

You sure? It’s completely working for me:

image
It’s probably due to where you set it up, and what type of script it is, it should be a ServerScript inside ServerScriptService & you can use the other print references to check if the Message formatted is valid:

local commands = {}

local prefix = "/"

commands.tp = function()
	print("Hello World")
end

game.Players.PlayerAdded:Connect(function(player)
	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]
		
		print("Message chatted:", message)
		print("Command:", cmdName)
		if commands[cmdName] then
			commands[cmdName]()
		end
	end)
end)
1 Like

Nothing prints for me and it is a ServerScript in ServerScriptService.

Edit - Ok it was in ServerStorage :confused:

Ah that explains it :sweat_smile: Try putting it in ServerScriptService to see if anything changes then, cause I believe that scripts would only run if they’re a descendant of:

  • ServerScriptService
  • workspace
  • Client Services, such as StarterPack, StarterGui, etc

Yeah I know how they run, I just drag and place without looking :laughing: