How I make a Admin Script? Part 2

I’m gonna make 2 scripts, which one the scripts have a folder with the player userid and name
and the other script is gonna store the data
(also the folder is gonna be in serverstorage because exploiters cant access that)

Hey, (late to the party but) what’s inside the Ranks? strings (name) or numbers (userid)

return {
	Ranks = {
		[3236301256] = true
	}
}

asss

return {
	Ranks = {
		3236301256
	}
}

And the main script to this:

local admins = require(script.Parent.Settings).Ranks

function IsAdmin(player)
    for _, v in pairs(admins) do
        if v:lower() == player.Name:lower() then
            return true
        end
    end
    
    return false
end

game.Players.PlayerAdded:Connect(function(player)
    if IsAdmin(player) == true then
        local ui = script.AdminGUI:Clone()
        ui.Parent = player.PlayerGui
    end
    
    player.PlayerGui.ChildAdded:Connect(function(child)
        if child:IsA("ScreenGui") and child.Name == "theAdminGuiName" and if IsAdmin(player) == false then
            player:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
        end
    end)
end

(make sure to change the gui name btw)

1 Like

uhhhhhh

1 Like

Whoops, my bad! Remove the if and change “theAdminGuiName” to your admin gui name. Here:

Should i do:

child.Name == script.AdminGUI.Name

?

If the admingui name is changed and is added to the player it wont kick them

Ok here, change that if statement to

if child:IsA("ScreenGui") and child.Name == "AdminGUI" and IsAdmin(player) == false then

No, not that what i was talking, i was talking this:

player.PlayerGui.ChildAdded:Connect(function(child)
		if child:IsA("ScreenGui") and child.Name == script.AdminGUI.Name and IsAdmin(player) == false then
			player:Kick("Reason: \n Exploiting to AdminScreen. \n Kicked By System")
		end
	end)

I’m confused but at least the script looks alright now.

i changed child.Name == “AdminGUI” to child.Name == script.AdminGUI.Name

Yeah, works

chars

  •   -
    

__/

is it possible the gui name be changed and the script waits 2 seconds and can still detect the gui?

Yes it can be changed. But only from the client. Since the script is in server, it won’t detect client changes. so no worries about the name changing!

1 Like

Should i test it now?
Or should i script more?

This should be it. You can give it a test! Make sure you have your output open in-case it throws out errors!

To open Output: View → Output

1 Like

imagem_2022-03-07_220908

Whoops, forgot it was UserId. My bad!

function IsAdmin(player)
    for _, v in pairs(admins) do
        if player.UserId == v then
            return true
        end
    end
    
    return false
end

Just change the IsAdmin() function to this.