Adding admin names in one script

So I have a trail in my game made only for admins but I would like to not have to make like 10 local scripts with different names in it for every admin Is there any way I could add a variable that is just all of the admins’ names in one script.

Code

wantedtrail = nil
script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.Name “arkboys99” then
wantedtrail = “AdminTrail”
workspace.Events.Trail:FireServer(wantedtrail)
end
end)

windtrail = nil
script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.Name == “arkboys99” then
wantedtrail = “AdminTrail”
workspace.Events.Trail:FireServer(wantedtrail)
end
end)
1 Like

Yes, use tables for it.

local admins = {
    'king_B99';
    'coolAdmin';
    'placeholder text lol';
}
local wantedtrail = nil
script.Parent.MouseButton1Click:Connect(function()
    if table.find(admins, game:GetService('Players').LocalPlayer.Name) then
        wantedtrail = “AdminTrail”
        workspace.Events.Trail:FireServer(wantedtrail)
    end
end)

I also recommend not giving the client access to your admin panel but that’s up to you.

2 Likes

Thank you so much :slight_smile:

1 Like

Oh yeah, also, I recommend using the player’s UserId because if the player changes their username they wont be an admin anymore

1 Like

Yeah, the most secure way would be to use a server script that checks the user ID but it’s up to the op. You could fire the event on the client but I highly recommend doing all security checks on the server.

2 Likes

Thanks for all the help, it is just a trail so I am not as worried about other players getting It but I will take a note of it.

1 Like