Admin script not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want to make a admin script

  1. What is the issue? Include screenshots / videos if possible!

i chat but there dont get any error and don’t happen what i script

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

i tried to view on youtube to see what i make wrong but that don’t helped me

game.Players.PlayerAdded:Connect(function(plr)
if table.find(_G.Admins, plr.Name) then
Warn(“A admin called “…plr.Name…” Has joined”)
plr.Chatted:Connect(function(plr,msg)
if msg == msg1 then
TeleportGui(plr)
end
end)
end
end)

oh and _G.Admins is from _G.Admins = {“pro_developer213”,“tudor22oi”}

why this don’t work?

warn is lowercase.

msg is the first parameter, you can read more here:

Please use the built-in script feature to make your code more readable.

2 Likes

Why not just put admin in this script? Also, _G is a pretty bad thing to use as _G Variables load last.

Also, why are you using “warn” and not print?

Hey pro_developer213, if you’re looking to make admin commands I suggest looking at some good tutorials such as this one by top contributor @EmeraldSlash.

You can add a codeblock like this:

```lua
print(“Hello, world!”)
```

print("Hello, world!")

Note that the ``` must be on their own line. You can learn more about Markdown here.

i like warn more that print becouse that orange color is cool

all works, but when i chat what needs to make isn’t making can someone help?

Warn is warn but i like to make my own functions

Can we see the code of what is meant to be making what it needs to make?

ok,

–// AdminTable \–

_G.Admins = {“pro_developer213”,“tudor22oi”}

_G.Banned = {“bananacool123rs”}

–// VerifyBann \–

local savebanns = game:GetService(“DataStoreService”)

local data = savebanns:GetDataStore(“Banns”)

local addata = savebanns:GetDataStore(“Admins”)

–// Custom function \–

local function Warn(WarnText)

warn(WarnText)

end

local function Warn(PrintText)

print(PrintText)

end

local function Banned(Player,Time)

game.Players[Player]:Kick(“You has ben banned, wait “…Time…” to get unbanned!”)

end

local function BannedKick(Player,Time)

game.Players[Player]:Kick(“You has ben banned, wait “…Time…” to get unbanned!”)

end

local function Kick(Player,AdminName)

game.Players[Player]:Kick(“You has ben kicked by “…AdminName…” if u want to raport he, text at me with his name and what he do”)

end

–// Sistem \–

game.Players.PlayerAdded:Connect(function(plr)

if not table.find(_G.Admins, plr.Name) and table.find(_G.Banned, plr.Name) then

BannedKick(plr, game.ReplicatedStorage.RecentTime.Value)

end

end)

while wait() do

data:SetAsync(“Banns”, _G.Banned)

end

while wait() do

addata:SetAsync(“Admins”, _G.Admins)

end

–// Chat Sistem \–

local function TeleportGui(plr)

local GuiClo = game.ReplicatedStorage.AdminGui:Clone()

GuiClo.Parent = plr.PlayerGui

end

local msg1 = “!Admin Me”

local function Warn(WarnText)

warn(WarnText)

end

game.Players.PlayerAdded:Connect(function(plr)

if table.find(_G.Admins, plr.Name) then

Warn(“A admin called “…plr.Name…” Has joined”)

plr.Chatted:Connect(function(msg,plr)

if msg == msg1 then

TeleportGui(plr)

end

end)

end

end)

i fund a problem, there is 2 Warn()
functions {at start}

‘plr’ is overriden as the recipient, if there even is one.
Consider changing it to just:

plr.Chatted:Connect(function(msg)

Also remember to use codeblocks as @ElliottLMz talked about.

i don’t used any ‘’’ in my script

It makes the code more readable on the forums.

Here is the code formatted

--// AdminTable \\–-
_G.Admins = {"pro_developer213","tudor22oi"}
_G.Banned = {"bananacool123rs"}
--// VerifyBann \\–-
local savebanns = game:GetService("DataStoreService")
local data = savebanns:GetDataStore("Banns")
local addata = savebanns:GetDataStore("Admins")
--// Custom function \\–-
local function Warn(WarnText)
	warn(WarnText)
end
local function Warn(PrintText)
	print(PrintText)
end
local function Banned(Player,Time)
	game.Players[Player]:Kick("You has ben banned, wait "..Time.." to get unbanned!")
end
local function BannedKick(Player,Time)
	game.Players[Player]:Kick("You has ben banned, wait "..Time.." to get unbanned!")
end
local function Kick(Player,AdminName)
	game.Players[Player]:Kick("You has ben kicked by "..AdminName.." if u want to raport he, text at me with his name and what he do")
end
--// Sistem \\–-
game.Players.PlayerAdded:Connect(function(plr)
	if not table.find(_G.Admins,plr.Name) and table.find(_G.Banned,plr.Name) then
		BannedKick(plr,game.ReplicatedStorage.RecentTime.Value)
	end
end)
while wait() do
	data:SetAsync("Banns",_G.Banned)
end
while wait() do
	addata:SetAsync("Admins",_G.Admins)
end
--// Chat Sistem \\–-
local function TeleportGui(plr)
	local GuiClo = game.ReplicatedStorage.AdminGui:Clone()
	GuiClo.Parent = plr.PlayerGui
end
local msg1 = "!Admin Me"
local function Warn(WarnText)
	warn(WarnText)
end
game.Players.PlayerAdded:Connect(function(plr)
	if table.find(_G.Admins,plr.Name) then
		Warn("A admin called "..plr.Name.." Has joined")
		plr.Chatted:Connect(function(msg,plr)
			if msg == msg1 then
				TeleportGui(plr)
			end
		end)
	end
end)

From a first glance:

Function Warn is defined 3 different times, and just calls another function. (just use warn or print)
Banned, BannedKick, and Kick functiuons all index the Players service with the Player object.
Writing over data with the same value, constantly.
Last section of code is never run, because of the infinite loops.

what u mean by: “Last section of code is never run, because of the infinite loops.”?

You have two non-terminating while wait loops running. Anything below the first one doesn’t run: no code after a while loop runs unless the while loop terminates. In the first place:

  1. You shouldn’t use while wait.
  2. You shouldn’t put DataStore calls in a while loop waiting at minimum time, your requests will get exhausted and you will be unable to perform other DataStore requests.
  3. You don’t need a while loop here at all.
3 Likes

i deleted it and now works, thanks ur the best scripter i see on developer forum also that _G function is very userfull :slight_smile: