#Script doesn't load clothing properly

1 messages · Page 1 of 1 (latest)

manic sparrow
#

Hey, been trying to make a "clothing updater"(Part with clickdetector in it). When activated it should update your clothing to a specific clothing based on your rank within a group. As of right now it doesn't do that at all and just takes off your clothes, but the new clothing is visible within the player in the explorer, but not visually.

POSTING SCRIPT BELOW

#
local GROUP_ID = 35929635

-- Rank to Uniform
local RankUniforms = {
    [255] = {
        Shirt = "rbxassetid://1234567890",
        Pants = "rbxassetid://103042840720197"
    },
    [200] = {
        Shirt = "rbxassetid://130216488762885",
        Pants = "rbxassetid://103042840720197"
    },
    [100] = {
        Shirt = "rbxassetid://5678901234",
        Pants = "rbxassetid://103042840720197"
    }
}

-- Uniform based on Rank
local function GetUniformForRank(rank)
    local bestMatch = nil
    for minRank, uniform in pairs(RankUniforms) do
        if rank >= minRank then
            if not bestMatch or minRank > bestMatch.rank then
                bestMatch = {rank = minRank, uniform = uniform}
            end
        end
    end
    return bestMatch and bestMatch.uniform or nil
end

-- Equip the uniform
local function EquipUniform(player)
    local rank = player:GetRankInGroup(GROUP_ID)
    local uniform = GetUniformForRank(rank)

    if not uniform then
        warn("No uniform found for rank", rank)
        return
    end

    local character = player.Character or player.CharacterAdded:Wait()

    local shirt = character:FindFirstChildOfClass("Shirt")
    if not shirt then
        shirt = Instance.new("Shirt")
        shirt.Name = "Shirt"
        shirt.Parent = character
    end
    shirt.ShirtTemplate = uniform.Shirt

    local pants = character:FindFirstChildOfClass("Pants")
    if not pants then
        pants = Instance.new("Pants")
        pants.Name = "Pants"
        pants.Parent = character
    end
    pants.PantsTemplate = uniform.Pants
end

ClickDetector.MouseClick:Connect(function(player)
    EquipUniform(player)
end)