I've been making a UI-based Admin Script and when you type a player's name and run it it doesn't show any errors or kick them from the game.
-- Script in ServerScriptService local SS = game:GetService("ServerStorage") local DSS = game:GetService("DataStoreService") -- "Allowed" users local Staff = {"Gavfoox","Warriorfoox","Player1","WhistleCats"} local Banned = {} --local Staff = {GroupId=0; RankId=0;} local Players = game:GetService("Players") local _B = DSS:GetDataStore("DS1_BANS") local _C = {} do for c=48,57 do table.insert(_C,string.char(c)) end for c=65,90 do table.insert(_C,string.char(c)) end for c=97,122 do table.insert(_C,string.char(c)) end end local debounce = false local function CommandPanel(Player) local _N = "???²?³????????????³?³??????" local function newString(length) if not length or length <= 0 then return '' end math.randomseed(os.clock()^5) _N = tostring(newString(length-1).._C[math.random(1,#_C)]) end newString() local panel = SS:WaitForChild("panel"):Clone() panel.Parent = Player.PlayerGui; panel.Name = _N local cmd = panel.main.commands local trigger = Instance.new("StringValue", panel) panel.TextButton.MouseButton1Click:Connect(function() if debounce then panel.main:TweenPosition(UDim2.new(.038,0,1.572,0), "Out", "Bounce", 1) wait(1) panel.main.Visible = false debounce = false elseif not debounce then panel.main.Visible = true panel.main:TweenPosition(UDim2.new(.038,0,.572,0), "In", "Bounce", 1) wait(1) debounce = true end end) for i,v in pairs(cmd:GetChildren()) do if v:IsA("TextButton") then v.MouseButton1Click:Connect(function() for d,b in pairs(cmd:GetChildren()) do if b:IsA("TextButton") then b.BackgroundColor3 = Color3.fromRGB(255,255,255) b.BackgroundTransparency = 1 b.TextColor3 = Color3.fromRGB(0,0,0) end end v.BackgroundColor3 = Color3.fromRGB(43,156,255) v.BackgroundTransparency = .55 v.TextColor3 = Color3.fromRGB(255,255,255) panel.main.action:TweenSizeAndPosition(UDim2.new(1,0,.281,0), UDim2.new(0,0,.719,0), "In", "Bounce", .5) wait(.5) for i,v in pairs(panel.main.action:GetChildren()) do v.Visible = true end trigger.Value = v.Name end) end end panel.main.action.run.MouseButton1Click:Connect(function() if trigger.Value == "a" then pcall(function() Players[panel.main.action.box.Text]:Kick("Don't break the rules. Kicked by "..Player.Name) end) elseif trigger.Value == "b" then pcall(function() _B:SetAsync(tostring(panel.main.action.box.Text), true) Players[panel.main.action.box.Text]:Kick("You have been banned for breaking the rules. Banned by "..Player.Name) end) end end) end local function IsStaffMember(Player) --[[for _,s in pairs (Staff) do if type(s) == "table" then local Rank = Player:GetRankInGroup(s.GroupId) if Rank >= (s.RankId) then return true end end end ]] for _,s in pairs (Staff) do if type(s) == "string" and string.lower(s) == string.lower(Player.Name) then return true end end return false end function onPlayerAdded(Player) if IsStaffMember(Player) then CommandPanel(Player) return end for i,v in pairs(Banned) do if _B:GetAsync(Player.Name) then Player:Kick("You are banned from this game.") end end end Players.PlayerAdded:Connect(onPlayerAdded) for _,p in pairs(Players:GetPlayers()) do onPlayerAdded(p) end
I do not actually know what the issue is here, but it isn't doing what it's expected to do when kicking/banning members.
So theres alot that can be changed and made better on yours.
I made my script very quickly before I had to leave.
Heres an example, Id recommend you to base yours off of mine. I dont have much time to explain, im sorry but im being rushed out the door rn.
local Players = game:GetService("Players") local Http = game:GetService("HttpService") local Datastore = game:GetService("DataStoreService") local Admins = {"Player1"} -- If you are going to use player names, make a function to convert to userid local GroupIds = { { Id = 00, Rank = 254 } } local NeededRank = 254 local Banned = Datastore:GetDataStore("Banned") function GetUserId(p) if type(p) == "number" then return p elseif type(p) == "userdata" then return p.UserId elseif type(p) == "string" then if Players:FindFirstChild(p) then return Players[p.Name].UserId else return tonumber(p) end end return nil end function GetPlayer(p) if type(p) == "userdata" then return p elseif type(p) == "number" then return Players:GetPlayerByUserId(p) elseif type(p) == "string" then if Players:FindFirstChild(p) then return Players[p] end end return nil end function IsAdmin(p) if Admins[p] or Admins[GetUserId(p)] then -- This way username or userid can be used return true end for _,v in next,GroupIds do local player = GetPlayer(p) if player and player:IsInGroup(v.Id) and player:GetRankInGroup(v.Rank) >= NeededRank then return true end end return false end -- For your guis, id recommand using a Module script Players.PlayerAdded:Connect(function(p) if Banned:GetAsync(p.UserId) then p:Kick("Banned") end p.Chatted:Connect(function(m) if IsAdmin(p) == true then if m:sub(0,3) == "/e " then m = m:sub(4) end if m:sub(0,5) == "!kick" then local target = m:sub(7) print(target) local player = Players:FindFirstChild(target) if player then player:Kick() else print'i prob got the subbing wrong, just +1' end elseif m:sub(0,4) == "!ban" then local target = m:sub(7) print(target) local player = Players:FindFirstChild(target) if player then Banned:SetAsync(player.UserId, true) player:Kick() end end end end) end)