Hello! I am trying to achieve a headless command, that works only for certain group ranks and ranks above that group rank. If that chat !headless then it will give them headless, but only if they are that rank in the group or above that rank in the group. Here is my script.
My goal is the replace the usernames with the group ranks, and then have a command where it will give them the headless instead of giving it to them automatically upon joining the game. Can anyone help me out?
local FreeProduct = {"inagurai", "26xpatata", "hcpefuls"}
-- / —————————— 🛠 —————————— \
local function FindPlayer(p)
for Num, Pler in pairs(FreeProduct) do
if Pler == p then
return true
end
end
end
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
if FindPlayer(p.Name) then
wait(0.02)
p.Character.Head.Transparency = 1
p.Character.Head.face:Destroy()
end
end)
end)
Made a few optimization changes this all you need:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
if player:GetRankInGroup(123456) == 200 then --Replace "123456" with your GroupId and "200" with rank
character.Head.Transparency = 1
character.Head.face:Destroy()
end
end)
end)
--game:GetService("TextChatService").ChatVersion = Enum.ChatVersion.TextChatService
local FreeProduct = {"inagurai", "26xpatata", "hcpefuls","NDavis06"}
local ChatCommand = Instance.new("TextChatCommand")
ChatCommand.Parent = game:GetService("TextChatService")
ChatCommand.PrimaryAlias = "!headless"
local GroupID = 123456
local Rank = 200
-- / —————————— 🛠 —————————— \
function FindPlayer(Name)
if (table.find(FreeProduct,Name)) then
return true
else
local Player = game:GetService("Players"):FindFirstChild(Name)
if (Player:GetRankInGroup(GroupID) >= Rank) then
return true
end
end
end
local Toggle = true
ChatCommand.Triggered:Connect(function(Source,Text)
if (FindPlayer(Source.Name)) then
print("Yayyaya")
local Player = game:GetService("Players"):FindFirstChild(Source.Name)
local Character = Player.Character
Character.Head.Transparency = 1
Character.Head.face:Destroy()
end
end)