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

How to give first player in server Adonis admin?

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?

2 comments

0

So, you only want the first player to get admin?

0

Yes. Only the first player joining the server (creating it) should get admin.

1 answer

✓ Accepted answer

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.

1 comment

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.

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