Admin Commands give weird response & are not working

Hi, I’m working on some admin commands for my game, but each time I execute a command it gives me some weird responses and I couldn’t find anything to it. The /viewguns and /changeteam command are also not working.
image

Part of the ServerScript

Plr.PlayerAdded:Connect(function(player)
	if Dev(player) or Admin(player) or Mod(player) then
--━━━━━━━━━━━━━━━━━━━━━━| Give Tool |━━━━━━━━━━━━━━━━━━━━━━━--
		player.Chatted:Connect(function(message)
			message = string.split(message, " ")
			if message[1]:lower() == "/gt" or "/Gt" or "/GT" then
				local tool = message[2]
				for i,v in pairs(Tools) do
					if tool == v.Name then
						v:Clone().Parent = player.Backpack
					end
				end
--━━━━━━━━━━━━━━━━━━━━━| Spawn Tool |━━━━━━━━━━━━━━━━━━━━━━━--
			elseif message[1]:lower() == "/st" or "/St" or "/ST" then
				local tool = message[2]
				for i,v in pairs(Tools) do
					if tool == v.Name then
						v:Clone().Parent = player.Backpack
						v:Clone().Parent = player.StarterGear
					end
				end
--━━━━━━━━━━━━━━━━━━━━━| Spawn Tool ALL |━━━━━━━━━━━━━━━━━━━━━━━--				
			elseif message[1]:lower() == "/Viewguns" then
				local names = {} -- table to store the children names
				for _, child in Tools:GetChildren() do
					-- iterate through the table using a generic for loop
					table.insert(names, child.Name) -- use the 'table.insert' function to add the value to the 'names' array
				end
				print(table.unpack(names)) -- Print all the children names
--━━━━━━━━━━━━━━━━━━━━━| CHANGE TEAM |━━━━━━━━━━━━━━━━━━━━━━━--
			elseif message[1]:lower() == "/ChangeTeam" or "/changeteam" or "/CHANGETEAM" then
				local team = message[2]
				if team == "DU" or "Du" or "du" then
					player.TeamColor = Teams:FindFirstChild("Dog union").TeamColor
				elseif team == "CAT" or "Cat" or "cat" then
					player.TeamColor = Teams:FindFirstChild("Cat union").TeamColor
				end
--━━━━━━━━━━━━━━━━━━━━━| KICK |━━━━━━━━━━━━━━━━━━━━━━━--				
			elseif message[1]:lower() == "/kick" then
				local targetName = message[2]:lower()
				local player = nil

				-- Find the player whose name matches the targetName
				for _, p in ipairs(game.Players:GetPlayers()) do
					if p.Name:lower() == targetName then
						player = p
						break
					end
				end

				if player then
					player:Kick("You have been kicked from the game.")
				end
			end
		end)
	end
end)
1 Like

This is unnecessary and could be causing you some problems:

if message[1]:lower() == "/gt" or "/Gt" or "/GT" then

Since you’re using :lower to convert the string to all lowercase characters, all you need to do is:

if message[1]:lower() == "/gt" then

I suggest you update them all to reflect this

Edit: @gunsgamertv In this line for example, you’re converting the string to lowercase but then comparing the result with a string that has a capital letter:

elseif message[1]:lower() == "/Viewguns" then

This statement will never be true unless you do:

elseif message[1]:lower() == "/viewguns" then
1 Like

It did fix it now thanks, but I’m still getting a lot of replies like these for each command executed
image

1 Like

That’s because of this line:

print(table.unpack(names))

Found here:

elseif message[1]:lower() == "/viewguns" then
				local names = {} -- table to store the children names
				for _, child in Tools:GetChildren() do
					-- iterate through the table using a generic for loop
					table.insert(names, child.Name) -- use the 'table.insert' function to add the value to the 'names' array
				end
				print(table.unpack(names))

At least I’m assuming it is since it’s the only print statement I see in the script

I replaced it with, but it still gives me the same responses

elseif message[1]:lower() == "/viewguns" then
				local names = {} -- table to store the children names
				for _, child in pairs(Tools) do
					print(child.Name)
				end```

To be honest I think a different script is causing that problem, since I don’t see any other print statements in the script unless it’s not the full script

Yeah, it was actually caused by another script, I was just Irritated as it always happened when I executed a command, Thanks for the help

1 Like

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