Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my Admin Commands Script erroring?

Asked by 9 years ago

The problem is the AutoUpdating feature of the Admin, but it keeps looping over and over again, non-stop, what have I done wrong? Here is the script;

local Admins = {"TheeDeathCaster","TheAlphaStigma"}
local Update = true

local function checkAdmin(name,ifAdmin)
for i = 1, #Admins do if name:lower() == Admins[i]:lower() then return true end end
return false
end

local function newUpdate()
Admins = {}
if game:GetService("ReplicatedStorage")and game:GetService("ReplicatedStorage"):FindFirstChild("ACV1") then
for i ,v in pairs(game:GetService("ReplicatedStorage").ACV1:GetChildren())do
if v.Name:lower() == "Admins" then table.insert(Admins, v.Value) end
end
end
wait(1)
game:GetService("ReplicatedStorage").ACV1:Destroy()
print("Updated list!")
end

local function startUpdating()
coroutine.resume(coroutine.create(function()
local new = nil
local old = nil
repeat wait(0)until game:GetService("InsertService") and game:GetService("ReplicatedStorage")
local newAdmin = game:GetService("InsertService"):LoadAsset(166559343)
if newAdmin:FindFirstChild("AdminCommandsV1", true) then
local startUpdate = newAdmin:FindFirstChild("AdminCommandsV1", true)
startUpdate.Disabled = true
if startUpdate:FindFirstChild("Version", true) then
new = startUpdate:FindFirstChild("Version", true).Value
if script:FindFirstChild("Version", true) then
old = script:FindFirstChild("Version", true).Value
if new > old then
local updateAdmins = Instance.new("BoolValue", game:GetService("ReplicatedStorage")) updateAdmins.Name = "ACV1"
for i , v in pairs(Admins)do local scr = Instance.new("StringValue", updateAdmins) scr.Name = "Admins" scr.Value = v end end
startUpdate.Parent = game:GetService("ServerScriptService")
startUpdate.Disabled = false
wait()
script:Destroy()
print("Update complete!")
else
newUpdate()
end
else
newUpdate()
end
else
newUpdate()
end
end))
end

local function Text(msg,time,par,type)
local m = Instance.new(type)
m.Text = msg
m.Parent = par
wait(time)
if m ~= nil then
m:Destroy()
end
end

local function onScript(codeString,newParent)
local newString = Instance.new("StringValue")
newString.Value = codeString
newString.Parent = newParent
repeat wait(0) until newString.Value == codeString
loadstring(newString.Value)();
end

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)

if msg:lower() == "update" then
coroutine.resume(coroutine.create(function()
if checkAdmin(plr.Name,false)and plr.userId == game.CreatorId then
startUpdating()
end
end))
end

if msg:lower() == "version" then
coroutine.resume(coroutine.create(function()
if plr and plr:FindFirstChild("PlayerGui") then
Text(script:FindFirstChild("Version", true).Value,2,plr.PlayerGui,"Message")
end
end))
end

if msg:lower():sub(1,2) == "m/" then
for i, v in pairs(game.Players:GetPlayers())do
coroutine.resume(coroutine.create(function()
if checkAdmin(plr.Name,false) and v:FindFirstChild("PlayerGui") then
Text(plr.Name..": "..msg:sub(3),2,v.PlayerGui,"Message")
end
end))
end
end

if msg:lower() == "reset" then
coroutine.resume(coroutine.create(function()
if plr and plr.Character then
plr.Character:BreakJoints()
plr:LoadCharacter()
end
end))
end

if msg:lower():sub(1,2) == "c/" then
coroutine.resume(coroutine.create(function()
if checkAdmin(plr.Name,false) then
onScript(msg:sub(3),game:GetService("ReplicatedStorage"))
end
end))
end

end)
end)

if Update then
print("Updating...")
startUpdating()
end

Answer this question