I was toying around with the Quick-Admin Command Script I found in The Roblox Developer Hub.
They also provided a Permissions Module where I could restrict the Admin Commands to certain players or certain ranks in a group, but I’m having trouble figuring out how to set the admin commands for certain ranks in my group only. (They have a setting to do that).
There aren’t any errors in the output either.
They weren’t very clear on the tutorial on how to specifically set group ranks for the commands, so I need help on how to.
I’ve tried to edit the scripts a few times but the end result is always “ValiantWind is not an admin” when I try to play test in Studio.
I will provide the original Permissions Module and the edits I’ve tried so far:
Original Module Script:
local Permission = {}
local Admins = {
--[UserId] = permission
}
local Groups = {
-- [GroupId] = {
-- [GroupRank] = permission
--}
}
--=======================================================================================================================================--
-- Permission
-- Properties
-- .Admins: table
-- .Groups: table
-- Functions
-- :GetAdmins() -> bool
-- :ContainsAdmin(number userId) -> bool
-- :SetUserPermission(number userId, number permission) -> bool
-- :GetUserPermission(number userId) -> number
-- :GetGroups() -> table
-- :ContainsGroupRank(number groupId, number rankId) -> bool
-- :SetGroupRankPermission(number groupId, number rankId, number permission)
-- :GetGroupRankPermission(number groupId, number rankId)
-- :GetUserGroupRankPermission(number userId)
--=======================================================================================================================================--
--=======================================================================================================================================--
--=======================================================================================================================================--
--=======================================================================================================================================--
-- UserId based admin functions
--=======================================================================================================================================--
--=======================================================================================================================================--
-- Returns the Admins table
function Permission:GetAdmins()
return Admins
end
-- Returns whether or not a given userId exists in Admins
local function ContainsAdmin(userId)
if not tonumber(userId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(userId), "number")) end
userId = tonumber(userId)
local isAdmin = Admins[userId]
if not isAdmin then return false end
if tonumber(isAdmin) then return true end -- True: user found in Admin table and is a numericalranking ? False: user not found in Admin table or found and not a number
error("Stored permission level is an invalid type")
return false
end
-- Sets the permission level for a given userId in Admins
function Permission:SetUserPermission(userId, permission)
if not tonumber(userId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(userId), "number")) end
if not tonumber(permission) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(permission), "number")) end
permission = tonumber(permission)
local success = (ContainsAdmin(userId) and Admins[userId] == permission)
if not success then
Admins[userId] = permission
success = (ContainsAdmin(userId) and Admins[userId] == permission)
end
return success
end
-- Returns the permission level for a given userId in Admins
function Permission:GetUserPermission(userId)
if not tonumber(userId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(userId), "number")) end
local isAdmin = ContainsAdmin(userId)
if not isAdmin then return false end
return Admins[userId]
end
--=======================================================================================================================================--
--=======================================================================================================================================--
-- GroupId/RankId based admin functions
--=======================================================================================================================================--
--=======================================================================================================================================--
-- Returns the Groups table
function Permission:GetGroups()
return Groups
end
-- Returns whether or not a given groupId->rankId exists in Groups
local function ContainsGroupRank(groupId, rankId)
if not tonumber(groupId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(groupId), "number")) end
groupId = tonumber(groupId)
if not tonumber(rankId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(rankId), "number")) end
rankId = tonumber(rankId)
local isGroup = Groups[groupId]
if not isGroup then return false end
local isRank = Groups[groupId][rankId]
if not isRank then return false end
if tonumber(isRank) then return true end
error("Stored permission level is an invalid type")
return false
end
-- Sets the permission level for a given groupId->rankId in Groups
function Permission:SetGroupRankPermission(groupId, rankId, permission)
if not tonumber(groupId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(groupId), "number")) end
groupId = tonumber(groupId)
if not tonumber(rankId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(rankId), "number")) end
rankId = tonumber(rankId)
if not tonumber(permission) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(permission), "number")) end
permission = tonumber(permission)
if not tonumber(groupId) then return false end
local success = (ContainsGroupRank(groupId, rankId) and Groups[groupId][rankId] == permission)
if not success then
if not Groups[groupId] then
Groups[groupId] = {
[rankId] = permission
}
else
Groups[groupId][rankId] = permission
end
success = (ContainsGroupRank(groupId, rankId) and Groups[groupId][rankId] == permission)
end
return success
end
-- Returns the permission level for a given groupId->rankId in Groups
function Permission:GetGroupRankPermission(groupId, rankId)
if not tonumber(groupId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(groupId), "number")) end
groupId = tonumber(groupId)
if not tonumber(rankId) then error(string.format("Incorrect value: given '%s' when expecting '%s'.", typeof(rankId), "number")) end
rankId = tonumber(rankId)
local isGroupRank = ContainsGroupRank(groupId, rankId)
if isGroupRank then return Groups[groupId][rankId] end
return nil
end
-- Returns the highest permission level for a given userId in Groups for all of that user's groups
function Permission:GetUserGroupRankPermission(userId)
local username = game.Players:GetNameFromUserIdAsync(userId)
local player = game.Players:FindFirstChild(username)
if not player then return false end
local highestPermission = 0
for groupId, groups in pairs(Groups) do
local isInGroup = player:IsInGroup(groupId)
if isInGroup then
local rankId = player:GetRankInGroup(groupId)
local hasRank = ContainsGroupRank(groupId, rankId)
if hasRank then
local groupRankPermission = Groups[groupId][rankId]
if groupRankPermission > highestPermission then highestPermission = groupRankPermission end
end
end
end
return highestPermission
end
return Permission
Here’s the edits I’ve done for the Group Table at the top that sets the Commands’ permissions:
(Please note that I’ve tried using numbers besides zero for setting the permissions)
Edit 1:
local Groups = {
[13622916] = { -- My Group ID
[255] = 0,
[254] = 0,
[253] = 0
}
}
Edit 2:
local Groups = {
[13622916] = { -- My Group ID
[255] = "0"
[254] = "0"
[253] = "0"
}
}
Edit 3:
local Groups = {
[13622916] = { -- My Group ID
[255] = 0
}
}
local Groups = {
[13622916] = { -- My Group ID
[255] = 0
}
}
Pinging Chat Scripting Expert @colbert2677 for help