Annoying HD Admin Issue

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a part that gives the player HD admin when touched.

  2. What is the issue? Include screenshots / videos if possible!
    Touching it does absolutely nothing.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on the devforum, and tried asking ChatGPT to review my code (I understand ChatGPT isn’t good at luau)

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Module = require(script.Parent.Parent.Settings)

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		table.insert(Module.Ranks[2], plr.UserId)
	end
end)

afaik doing table.insert on the Admin module is useless, because it loads itself only once and doesn’t save to the game,
since HD admin has a (semi) documented Rank API, something like this reddit post could help: (see code snippet)
Reddit - How do u make so if u touch a part U get a rank with hd admin

i think that is an old version of hd, as the scripts used in it don’t work with the latest version

edit two: if you want permanent admin, change rankType to “Perm”
RobloxStudioBeta_Hy4aZFjSLo-ezgif.com-gif-maker

partadmin.rbxl (89.6 KB)
that’s weird… it works fine for me
make sure the script is inside the part (and not a model) so the .Touched event fires

local rank = "Admin"

local rankType = "Server"

local players = game:GetService("Players")

local hdMain = require(game:GetService("ReplicatedStorage"):WaitForChild("HDAdminSetup")):GetMain()

local hd = hdMain:GetModule("API")

local rankId = hd:GetRankId(rank)

local touchPart = script.Parent

local touchedPlayers = {}

touchPart.Touched:Connect(function(hit)

local character = hit.Parent

local player = players:GetPlayerFromCharacter(character)

if player and not touchedPlayers[player.UserId] then

touchedPlayers[player.UserId] = true

hd:SetRank(player, rankId, rankType)

-- Allow the player to touch again after a short delay

delay(1, function()

touchedPlayers[player.UserId] = nil

end)

end

end)

ok so, for some reason when i copy pasted what was in your game into mine it just decided to work? thanks anyway :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.