You can write your topic however you want, but you need to answer these questions:
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.
What is the issue? Include screenshots / videos if possible!
Touching it does absolutely nothing.
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)
edit two: if you want permanent admin, change rankType to “Perm”
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)