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

Get player rank from HD Admin?

Asked by 3 years ago

I have this function in a script that allows the player to bypass the anti-exploit if it returns true.

local function HasAdmin(id)
    for i = 1,#Administrators do
        if (string.upper(id) == string.upper(Administrators[i])) then 
            return true 
        end
    end 
    local player = game.Players:GetNameFromUserIdAsync(id)
    if game.Workspace:FindFirstChild(player) then
        if game.Workspace:FindFirstChild(player).Humanoid.Health < 5 then
            return true
        end
    end
    local checkModule = require(script.CheckRank)

    checkModule.checkRank(player) -- tried a module script bc all of the HD admin scripts were inside modules (idk how use modules. this might be wrong o-o)


--[[ First attempt. Didn't work 

    local main = _G.HDAdminMain
    local plrRank = main.pdata[player].Rank
    if plrRank >= 1.5 then
        return true
    end
]]


    return false 
end

I want it so if the players rank is higher than something then it will return true. This is what I have in my module script.

local module = {}

local main = _G.HDAdminMain

function module:checkRank(player)
    local plrRank = main.pdata.Rank
    if plrRank >= 1.5 then
        return true
    end
    return false
end



return module

Error: ServerScriptService.Anti-Exploit.MuffinHacks.CheckRank:6: attempt to index nil with 'Rank'

Image: https://cdn.discordapp.com/attachments/789594500922081320/839367100506308608/yudduly.PNG

1 answer

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

I have looked through the code of HDAdmin. One reason your script isn't working is because your script runs before _G assign HDAdminMain to the MainFramework, and also because the data for the server is stored in main.pd[player]

local module = {}    

function module:checkRank(player)
    local main = _G.HDAdminMain
    local plrRank = main.pd[player].Rank
    print(plrRank) -- Prints 5 for owner
    if plrRank >= 1.5 then
        return true
    end
    return false
end

return module

0
uh does it need to be in the function or somethin? it still error right when I join and after hd icon loads. BulletproofVast 1033 — 3y
0
A better way would be to get the _G.HDAdminMain inside the checkRank function so that when you run the function, it's gonna get the HDAdminMain inside the function and then by the time, you run the function, _G would have loaded the variables, and not when the module is required. I have edited the script AnasBahauddin1978 715 — 3y
0
Also, pretty sure that it's main.pd[player] on the server, and main.pdata on the client. Cannot confirm since I don't use HD Admin anymore AnasBahauddin1978 715 — 3y
Ad

Answer this question