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

Admin Menu Help?

I only want certain people to get into the admin menu. Help? It still lets everybody in.

local adminb = menu.Admin
local adminmenu = script.Parent.AdminMenu
function adminbc() --admin button
if game.Players.LocalPlayer.Name == "Andorks" or "Player1" then
	adminmenu.Visible = true
    menu.Visible = false
end	
end

script.Parent.Menu.Admin.MouseButton1Click:connect(adminbc) --admin button

3 comments

0

If my answer is correct, please hit accept answer.

0

Okay, let me try it out. Thanks!

0

@Andorks Alright, let me know how it goes!

1 answer

✓ Accepted answer

The problem is game.Players.LocalPlayer.Name == "Andorks" or "Player1"

The computer tries to simplify that into true or false, and can't. If you want to use that syntax, use the following code:

game.Players.LocalPlayer.Name == "Andorks" or game.Players.LocalPlayer.Name == "Player1"

Hence:

repeat wait() until game.Players.LocalPlayer;

local adminb = menu.Admin
local adminmenu = script.Parent.AdminMenu
function adminbc() --admin button
	if game.Players.LocalPlayer.Name == "Andorks" or game.Players.LocalPlayer.Name == "Player1" then
    	adminmenu.Visible = true
    	menu.Visible = false
	end 
end

script.Parent.Menu.Admin.MouseButton1Click:connect(adminbc) --admin button

Alternatively, you could put the admin names in a table and loop through it to see if the LocalPlayer's name matches any of the values in the table.

Understand that by clicking here.

repeat wait() until game.Players.LocalPlayer;

local adminb = menu.Admin
local adminmenu = script.Parent.AdminMenu
local admins = {"Andorks","Player1","NlLES"}
function adminbc() --admin button
	for index,Name in pairs(admins) do --Run the following chunk of code once for each value in the "admins" table
		if game.Players.LocalPlayer.Name == Name then
    		adminmenu.Visible = true
    		menu.Visible = false
		end 
	end
end

script.Parent.Menu.Admin.MouseButton1Click:connect(adminbc) --admin button

11 comments

0

It keeps saying "attempt to call a nil value

0

What line does it say?

0

This is all it says: http://prntscr.com/7uclnj

0

I think it's referring to line 10. "menu.Visible = false" The script doesn't have "menu" defined.

0

Let me define it.

0

Oh, I see. I had it defined in script, I just had a capital M instead of a lowercase. Thanks!

0

@Andorks Yup! Good luck scripting!

0

@Validark, For some reason it doesn't work in-game.

0

Is it in a LocalScript?

0

Let me put it in one.

0

Now it does! Thanks again!

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