Auto Uniform script not working

    local character = nil
    if player:GetRankInGroup("4950081") >= 4 then -- and player:GetRankInGroup("4950081") ~= 255 and player:GetRankInGroup("4950081") ~= 253 then
        if player.Character then
            character = player.Character
            character = player.Character
        character:WaitForChild("Shirt").ShirtTemplate = "rbxassetid://4970179439"
        character:WaitForChild("Pants").PantsTemplate = "rbxassetid://2975715047"

The aim of this script is to apply items of clothing when people meet a certain criteria inside of a group. However, only the pants are working and it is showing no shirt. Any idea?

There’s no errors inside of the console.

Ignore the – and player:GetRankInGroup(“4950081”) ~= 255 and player:GetRankInGroup(“4950081”) ~= 253 then

That’s just script stuff I need to remember at some point.

1 Like

I would look into using Humanoid Description

An easy fix for this could be (I don’t recommend it) is to check if the player has a shirt or pants. If they do, then set their shirt/pants id set to the one you want cloned. If you can’t find it use and add a shirt/pants to the character with your pants and shirt ID.

Shirt doesn’t work because you’re setting the ShirtTemplate to a Shirt asset, not a Shirt Image asset. The id you should be inputting for ShirtTemplate is 4970179411.

That being said, there’s a few fundamental mistakes that haven’t been addressed in your code.

I’m not too sure what’s going on with that character if statement in PlayerAdded but I don’t think it’s your intention to only run this code once, is it? If not, then you should be using the CharacterAdded event and getting rid of all this work here.

The next thing is that you’re assuming a Shirt and Pants will exist for all characters: they don’t. You’re using WaitForChild so if a player doesn’t have one or the other, you’ve now indefinitely suspended a thread which is going to cause problems in your game up to leaking memory. What you should do instead is find a Shirt object and if one doesn’t exist, then create one. Modify the ShirtTemplate from there instead.

I recommend using HumanoidDescriptions here. You can get the current applied description to a character, update the shirts and pants and then apply that back when they load in. Not immediately because it’ll be overwritten by internal rig building and appearance loading processes though.