So I made this script to equip a player with clothes when they touch it. I want to add it to where a specific rank gets specific clothing. I have treid countless things but cant get it too work for me. Any help?

local rank = 2 -- The rank the player will need to get through (out of 255)
local groupID = 2616467 -- The group ID the player must be in

script.Parent.Touched:connect(function(hit)
    if (hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)) then
        if (game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank) then
            script.Parent.CanCollide = false
            script.Parent.Transparency = 1
            wait(1)
            script.Parent.CanCollide = true
            script.Parent.Transparency = 1
        else
            hit.Parent:FindFirstChild("Humanoid").Health = 0
        end
    end
end)








script.Parent.Touched:connect(function(h)
    if h.Parent:FindFirstChild("Humanoid") then
        for _,v in pairs(h.Parent:GetChildren()) do
            if v:IsA("Shirt") or v:IsA("Pants") then
                v:Destroy()
            end
        end
        local shirt = Instance.new("Shirt", h.Parent)
        shirt.ShirtTemplate = "rbxassetid://" .. "321199918"
        shirt.Name = "Leedle1"
        local pants = Instance.new("Pants", h.Parent)
        pants.PantsTemplate = "rbxassetid://" .. "321200010"
        pants.Name = "Leedle2"
    end
end)