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

Admin Menu Help?

Asked by
Andorks 23
9 years ago

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
0
If my answer is correct, please hit accept answer. Validark 1580 — 9y
0
Okay, let me try it out. Thanks! Andorks 23 — 9y
0
@Andorks Alright, let me know how it goes! Validark 1580 — 9y

1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
9 years ago

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
0
It keeps saying "attempt to call a nil value Andorks 23 — 9y
0
What line does it say? Validark 1580 — 9y
0
This is all it says: http://prntscr.com/7uclnj Andorks 23 — 9y
0
I think it's referring to line 10. "menu.Visible = false" The script doesn't have "menu" defined. Validark 1580 — 9y
View all comments (7 more)
0
Let me define it. Andorks 23 — 9y
0
Oh, I see. I had it defined in script, I just had a capital M instead of a lowercase. Thanks! Andorks 23 — 9y
0
@Andorks Yup! Good luck scripting! Validark 1580 — 9y
0
@Validark, For some reason it doesn't work in-game. Andorks 23 — 9y
0
Is it in a LocalScript? Validark 1580 — 9y
0
Let me put it in one. Andorks 23 — 9y
0
Now it does! Thanks again! Andorks 23 — 9y
Ad

Answer this question