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.
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)