I need help with commands

I’m making admin commands for my game but whenever I try to run :test it’s doesn’t work, there’s no errors in the output.

local config = require(game:GetService("ServerScriptService").Solar.Setup:FindFirstChild("Config"))
local Datastores = game:GetService("DataStoreService")
local PlayerService = game:GetService("Players")

function CheckPermLevel(userId)
	if table.find(config.SuperAdmin, userId) then
		return 3
	elseif table.find(config.Admin, userId) then
		return 2
	elseif table.find(config.Mod, userId) then
		return 1
	elseif userId == game.CreatorId then
		return 4
	elseif table.find(config.Banned, userId) then
		return -1
	else
		return 0
	end
end

function CheckBan(userId)
	local PlayerKey = Datastores:GetDataStore(userId.."91213924014EpzS@laréâ")
	if CheckPermLevel(userId) >= 1 then
		if table.find(config.Banned, userId) then return table.remove(config.Banned, userId) end
		if PlayerKey:GetAsync(userId.."91213924014EpzS@laréâ","-BAN") then return PlayerKey:GetAsync(userId.."91213924014EpzS@laréâ") end
	else
		if PlayerKey:GetAsync(userId.."91213924014EpzS@laréâ","-BAN") or table.find(config.Banned, userId) then
			local getPlrNameByID = PlayerService:GetNameFromUserIdAsync(userId)
			getPlrNameByID:Kick("[Solar] You are banned from this server.")
			end
		end
	end

game.Players.PlayerAdded:Connect(function(player)
	local PlayerKey = Datastores:GetDataStore(player.UserId.."91213924014EpzS@laréâ")
	if PlayerKey:GetAsync(player.UserId.."91213924014EpzS@laréâ","-BAN") or table.find(config.Banned, player.UserId) then
		CheckBan(player.UserId)
	else
		PlayerKey:SetAsync(player.UserId.."91213924014EpzS@laréâ")
		if CheckPermLevel(player.UserId) >= 1 then
			player.Chatted:Connect(function(msg)
				local argument = msg:split(" ")
				if argument[1] == ":test" then
					if CheckPermLevel(player.UserId) == 4 then
						return print("test")
					else
						return warn("Not high enough to execute "..config.Prefix.."test, rank: "..CheckPermLevel(player.UserId))
					end
				end
			end)
		end
	end
end)

Bump since I still need help with this^

I’m not 100% this is the problem but try this
local argument = string.split(msg, " ")

Remove the returns. (characters)

Probably isn’t the problem since this basically makes a space.

I’ll try. I’ll let you know of what happens

I removed the returns, played the game and I still don’t have anything printed.

Yeah it’s does return 4. If the player has the creator’s userId, it’s would return 4. But I think I found the problem: I made the prefix a table which is uh.

Edit: changing the prefix from a table to a string didn’t work

Every few lines, print something. Tell me where it stops.

Alright let me check the output

stops at

game.Players.PlayerAdded:Connect(function(player)
	local PlayerKey = Datastores:GetDataStore(player.UserId.."91213924014EpzS@laréâ")
	print("oh hey the player key got registered")
	if PlayerKey:GetAsync(player.UserId.."91213924014EpzS@laréâ","-BAN") or table.find(config.Banned, player.UserId) then
		CheckBan(player.UserId)
else
-- code code

Alright I solved the issue, I basically put a “else” after checkban but in all cases we check the ban, so I just removed it since anybody banned is instant kicked.

1 Like