Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a script that adds a shirt if a player dosent have one?

I need to have a script add a shirt if there is no shirt on the player because the script breaks when the player dosen't have a shirt.

Code It dosen't seem to add the shirt. Character is R15

local shirtid = 1453678633


game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
            local shirt = chr:FindFirstChild("Shirt")
                local nshirt = Instance.new("Shirt", chr)
                nshirt.Name = "Shirt"
                nshirt.ShirtTemplate = "rbxassetid://" ..shirtid
            end

1 comment

0

1 answer

✓ Accepted answer
local ShirtID = 1453678633

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAppearanceLoaded:Connect(function(chr)
        local Shirt = chr:FindFirstChildOfClass("Shirt")
        if not Shirt then
            local Shirt = Instance.new("Shirt")
            Shirt.Parent = chr
            Shirt.ShirtTemplate = "rbxassetid://" .. ShirtID
        end
    end)
end)

Wiki:

FindFirstChildOfClass

Don't forget to mark my answer as the solution if it solved your problem :)

6 comments

0

This is the way to do it.

0

Didn't work

0

Are there any errors in the output?

0

The Shirt has been moderated, that's why it doesn't work

0

I tried a diffrent shirt and it dosen't work

0

add me on discord JR#0542

This discussion is preserved as it was. New answers, comments, and votes are closed.