Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My custom admin script won't give me admin for some reason, any fixes?

My admin script is supposed to give certain UserIds access to commands but it gives them admin and not me, I've changed the UserId on the local "ADMANS" but it still dosent give me anything, heres my code:

local bill = game:GetService("ServerStorage"):WaitForChild("bruhboard")
local function sendText(str,v)
	if (v == nil) then
		v = true
	end
	game:GetService('ReplicatedStorage').Client:FireAllClients("setText",str,v)
end
local ADMANS =
{
88130316,

}
local eventyboys = game.ReplicatedStorage.Events
local function Split(str)
	local names = {}
 
	for name in str:gmatch("[^ ]+") do
		table.insert(names, name)
	end
 
	return names
end
local function shorty(Name,Player)
	if (string.lower(Name) == "me") then
		return Player
	end
for _,x in pairs(game:GetService("Players"):GetPlayers()) do
if (string.sub(string.lower(x.Name),0,string.len(string.lower(Name))) == string.lower(Name)) then
return x
end
end
return nil
end

local Commands = {}
Commands[";ff"] = function(args,plr)
	if (shorty(args[2],plr)) then
		Instance.new("ForceField",shorty(args[2],plr).Character)
	else
		game:GetService("ReplicatedStorage").Event:FireClient(plr,"message","Sorry, could not find player by the name of "..args[2].."!",Color3.new(1,0,0))
	end
end
Commands[";dust"] = function(args,plr)
	if (shorty(args[2],plr)) then
		shorty(args[2],plr).Character.Humanoid.Health = 0
	else
		game:GetService("ReplicatedStorage").Event:FireClient(plr,"message","Sorry, could not find player by the name of "..args[2].."!",Color3.new(1,0,0))
	end
end
Commands[";rage"] = function(args,plr)
	if (shorty(args[2],plr)) then
		shorty(args[2],plr).Character.Head.face:Destroy()
		local REE = game.ServerStorage.Decals.AngryFace:Clone()
		REE.Parent =shorty(args[2],plr).Character.Head
		local AAA = game.ServerStorage.Sounds.Rage:Clone()
		AAA.Parent = shorty(args[2],plr).Character.Head
		AAA:Play()
		wait(7)
				local powie = game.ServerStorage.Sounds.BOOM:Clone()
		powie.Parent = shorty(args[2],plr).Character.Head
		powie:Play()
		local boom = Instance.new("Explosion", workspace)
		boom.Position = shorty(args[2],plr).Character.UpperTorso.Position
	else
		game:GetService("ReplicatedStorage").Event:FireClient(plr,"message","Sorry, could not find player by the name of "..args[2].."!",Color3.new(1,0,0))
	end
end
Commands[";cmds"] = function(args,plr)
	eventyboys.AskedForCmds:FireAllClients(plr)
end
Commands[";lit"] = function(args,plr)
	if (shorty(args[2],plr)) then
		local litty = Instance.new("Fire", workspace)
		litty.Parent = shorty(args[2],plr).Character.UpperTorso
		litty.Size = 10
		litty.Heat = 20
		local lit = game.ServerStorage.Sounds.lit:Clone()
		lit.Parent = shorty(args[2],plr).Character.UpperTorso
		lit:Play()
		repeat wait(.005) shorty(args[2],plr).Character.Humanoid.Health = shorty(args[2],plr).Character.Humanoid.Health - 1 print("ow!") until shorty(args[2],plr).Character.Humanoid.Health == 0
		lit:Stop()
		litty.Enabled = false
		wait(5)
		litty:destroy()
		else
		game:GetService("ReplicatedStorage").Event:FireClient(plr,"message","Sorry, could not find player by the name of "..args[2].."!",Color3.new(1,0,0))
	end
end
Commands[";nukeevent"] = function(args,plr)
	local nook = game.ServerStorage.Stuff.nuke:Clone()
	nook.Parent = workspace
	game.StarterGui.UI.boOp:Play()
	sendText("ADMIN "..plr.Name.." HAS SUMMONED A NUKE, RUN FOR YOUR LIFE!!!!!")
end
Commands[";kick"] = function(args,plr)
	if (shorty(args[2],plr)) then
		shorty(args[2],plr):Kick("You've been kicked from the server by "..plr.Name..".")
	else
		game:GetService("ReplicatedStorage").Event:FireClient(plr,"message","Sorry, could not find player by the name of "..args[2].."!",Color3.new(1,0,0))
	end
end
Commands[";burntheashes"] = function(args,plr)
	if (shorty(args[2],plr)) then
		local clone = bill:Clone()
		local litty = Instance.new("Fire", workspace)
		litty.Parent = shorty(args[2],plr).Character.UpperTorso
		litty.Size = 10
		litty.Heat = 20
		local lit = game.ServerStorage.Sounds.lit:Clone()
		lit.Parent = shorty(args[2],plr).Character.UpperTorso
		lit:Play()
		repeat wait(.005)shorty(args[2],plr).Character.Humanoid.Health = shorty(args[2],plr).Character.Humanoid.Health - 1 print("ow!") until shorty(args[2],plr).Character.Humanoid.Health == 0
		clone.Parent = shorty(args[2],plr).Character.LowerTorso
		clone.TextLabel.Text = "451"
		clone.TextLabel.TextColor3 = Color3.new(255, 0, 0)
		lit:Stop()
		litty.Enabled = false
		wait(5)
		clone:Destroy()
		litty:destroy()
		else
		game:GetService("ReplicatedStorage").Event:FireClient(plr,"message","Sorry, could not find player by the name of "..args[2].."!",Color3.new(1,0,0))
	end
end
game:GetService("Players").PlayerAdded:Connect(function(_plr)
for _,v in pairs(ADMANS) do
		if (v == _plr.UserId) then
			if (_plr.UserId ~= ADMANS[1]) then
				eventyboys.Yes:FireAllClients(_plr)
_plr.Chatted:Connect(function(msg)
				if (string.sub(msg,0,1) == ";") then
				local args = Split(msg)
				if (Commands[args[1]] ~= nil) then
				Commands[args[1]](args,_plr)
end
end
end)
end
end
end
end)


1 answer

✓ Accepted answer

I believe the problem in your script is the part where the script compares the player's UserId itself:

game:GetService("Players").PlayerAdded:Connect(function(_plr)
	for _,v in pairs(ADMANS) do
		if (v == _plr.UserId) then
			if (_plr.UserId ~= ADMANS[1]) then
				eventyboys.Yes:FireAllClients(_plr)
				_plr.Chatted:Connect(function(msg)
					if (string.sub(msg,0,1) == ";") then
						local args = Split(msg)
						if (Commands[args[1]] ~= nil) then
							Commands[args[1]](args,_plr)
						end
					end
				end)
			end
		end
	end
end)

If we check the part where the script compares the UserId in the if . . . then(s), we find these two comparisons:

if (v == _plr.UserId) then
	if (_plr.UserId ~= ADMANS[1]) then

The player would pass the first if . . . then since v == _plr.UserId will return true for the first value in the table. Hoever, the second if . . . then fails, since _plr.UserId will be equal to ADMANS[1] and hence the script fails to pass the second if . . . then. I believe that's what's wrong with your script and this would be a fix for the same:

game:GetService("Players").PlayerAdded:Connect(function(_plr)
	for _,v in pairs(ADMANS) do
		if (v == _plr.UserId) then
			eventyboys.Yes:FireAllClients(_plr)
			_plr.Chatted:Connect(function(msg)
				if (string.sub(msg,0,1) == ";") then
					local args = Split(msg)
					if (Commands[args[1]] ~= nil) then
						Commands[args[1]](args,_plr)
					end
				end
			end)	
		end
	end
end)

That's it from me! Feel free to ask any questions or point out any mistakes, I would appreciate it if you would be able to tell me if this fix worked or not.

2 comments

0

I'll accept the answer if it works, I'm going to test this out, thank you! :D

0

It worked! Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.