Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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

0
The shirt is [ Content Deleted ]. https://www.roblox.com/catalog/1453678633/Content-Deleted y3_th 176 — 4y

1 answer

Log in to vote
1
Answered by
Filipalla 504 Moderation Voter
4 years ago
Edited 4 years ago
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 :)

0
This is the way to do it. proqrammed 285 — 4y
0
Didn't work KronxGoat 50 — 4y
0
Are there any errors in the output? Filipalla 504 — 4y
0
The Shirt has been moderated, that's why it doesn't work Filipalla 504 — 4y
View all comments (2 more)
0
I tried a diffrent shirt and it dosen't work KronxGoat 50 — 4y
0
add me on discord JR#0542 KronxGoat 50 — 4y
Ad

Answer this question