I want to create my own admin script like Epixs as then I can use mine and not anyone else's.
How do you create your own admin script?
3 answers
If you are looking to make a chat based admin script take a look at this Click Here
All you will need to do is add some validation so that only admins can use it. I cannot show you as I don't have roblox studio on this computer at the moment.
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg == "reset" then
player.Character:BreakJoints()
end
end)
end)
Creating a Commands system is not all that easy; It takes a lot of Math, and String Manipulation. However, once you get used to creating commands, it's gets a lot easier, but, there is the issue of Who's an Admin?, How do I restrict it to certain people?, How do I create a command? This is a problem that some of the most Famous Admin Commands Creators encountered (E.x. Person299, Kohltastrophe) and prevented/did/fixed. Now, with all this in mind, let's start the code;
local Admins = {"TheeDeathCaster"} --This is the 'Admins' table, where it will store Strings of User's Name to check a Joining Users name later on
function CheckAdmin(plr) --Here is the function to check if a Player's name is in the 'Admins' list/table
for i = 1, #Admins do --This is the 'for' loop; This will loop through the Number of 'Strings' within the 'Admins' table
if plr:lower() == Admins[i]:lower() then --If variable 'plr' is equal to the current position in 'Admins' then
return true --It'll return true, allowing the Player access
end --Ends the chunk for the 'if' statement
end --Ends the chunk for the 'for' loop
return false --But, if not, it will return 'false', or, will not allow access
end --Ends the chunk to the function
function AdminControl(plr) --Here is the function that will set the Player Chatted-Commands
if CheckAdmin(plr.Name) then --The 'if' statement is checking if the Player is an 'Admin'
print(plr.Name.." is an Admin!") --If so, it'll print 'Player1 is an Admin!'
end --Ends the chunk for the 'if' statement
plr.Chatted:connect(function(msg) --Here is the 'Chatted' function, which will trigger everytime the Player has Chatted; Variable 'msg' is the 'String' the Player chatted
if msg:lower() == "reset" then --If the Variable 'msg' is equal to 'reset' then
plr:LoadCharacter() --Will reset the Player's Character
end --Ends the chunk for the 'if' statement
if not CheckAdmin(plr.Name) then return end --If the Player is not an Admin, however, then it will not allow the Player access to the commands; That is where the 'CheckAdmin' function comes in, if the name does not match, it will return
if msg:lower():sub(1,2) == "m/" then --If the commands first two Characters start with 'm/' then, or, as Person299 explains 'This part checks if the first part of the message is m/'
print(msg:sub(3)) --Will print the Characters after the two Characters
end --Ends the chunk for the 'if' statement
end) --Ends the chunk to the '.Chatted' function/event
end --Ends the chunk to the function
game.Players.PlayerAdded:connect(AdminControl) --The 'PlayerAdded' event will fire whenever a Player joins the Server, and will connect 'AdminControl' to the Player
Information not mentioned:
Sub-Strings- Gets the Position of a String where it is located;
local String = "I'm a string!"
print(String:sub(1,5),String:sub(6)) --Output: 'I'm a string!' This is because method 'sub' got the Characters position within the given Numbers/Position place
If statements- Checks if a(n) Condition (Value, Variable, Bool, ect.) is true (equal) to the Argument (Variable, Value, ect.)For loop- Is a loop that will loop through a set of Numbers (Given the Argument (E.x. Number in a Table, String, or Number)) and will stop execution when a Value returnsnil
Hope this helped!
ROBLOX Admin command scripts are not easy at all to make, and if you haven't had years of experience with *advanced * scripting you won't be able to do much.
This discussion is preserved as it was. New answers, comments, and votes are closed.
