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

How to give first player in server Adonis admin?

Asked by 3 years ago

So, my goal is to get the first player in a server to recieve Adonis owner admin.

local Players = game:GetService("Players")
local player = Players.LocalPlayer

if player.MembershipType == Enum.MembershipType.Premium then
        local data = {
            Settings = {
            Moderators = {player.Name}
            };
        }
    require(359948692)(data) -- adonis API module 
end 

This code will supposedly give you admin if placed in server and if you are premium. I have not tried it, but it can give an idea of how the admin is given.

I then tried making this to give everyone admin. My plan was to later on add a line destroying the script after someone was given the admin. (test):

local Players = game:GetService("Players")
local player = Players.LocalPlayer

        local data = {
            Settings = {
            Moderators = {player.Name}
            };
        }
    require(359948692)(data) -- adonis API module 

And that did not work. Any ideas?

0
So, you only want the first player to get admin? NotTheChara 191 — 3y
0
Yes. Only the first player joining the server (creating it) should get admin. tim458458 29 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

I don't know much with Adonis Admin but according to your logic, you can make a variable and set it to true after the first player joins. Here's how I will do it and it should be done in a server script.

local Players = game:GetService("Players")
--local player = Players.LocalPlayer   --You cannot get LocalPlayer on server, this can only be done on the client

firstPlayerJoined = false   --I like to use global variables to make these kinds of variables

Players.PlayerAdded:Connect(function(plr)   --We detect when a player joins.
    if not firstPlayerJoined then   --Then, we detect if that variable is false or not.
        firstPlayerJoined = true   --If it is false, then set the variable to true so other runs can't get here.

        local data = {   --After this line is the same as your code.
            Settings = {
                Moderators = {plr.Name}
            };
        }
        require(359948692)(data)
    end
end)

I tested it and it worked well.

0
Yep, appears to work, however I still don't get any admin, however that is probably an issue with the script giving the admin. Great solution, I'll have to get the admin part fixed another way. Thanks. tim458458 29 — 3y
Ad

Answer this question