Ad
Log in to vote
0

Why Isn't the new shirt and pants not applying to the person?

Asked by 16 days ago

Hello! I am making a tool that If you activate It via clicking the screen with It equipped It will change your avater to a backrooms person, however while I was working on removing shirts and pants, I stumble across a problem, the problem Is that the new shirts and pants aren't applying

script:

local tool = script.Parent

tool.Activated:Connect(function()
    local char = tool.Parent:FindFirstChild("Humanoid")
    local Model = char.Parent
    local Shirt = Instance.new("Shirt")
    local Pants = Instance.new("Pants")

    if char.Parent:FindFirstChild("Shirt") and char.Parent:FindFirstChild("Pants") then
        char.Parent:FindFirstChild("Shirt"):Destroy()
        char.Parent:FindFirstChild("Pants"):Destroy()
    end

    char.WalkSpeed = 20
    char.MaxHealth = 150
    char.Health = 150
    Shirt.Parent = Model
    Shirt.ShirtTemplate = "https://web.roblox.com/catalog/8878853958/Async-Hazmat-Suit-Shirt-The-Backrooms"
    Pants.Parent = Model
    Pants.PantsTemplate = "https://web.roblox.com/catalog/9575156100/Black-Shoes-Async-Hazmat-Suit-The-Backrooms"
    tool:Destroy()
end)

1 answer

Log in to vote
0
Answered by
Xientra 17
16 days ago
Edited 16 days ago

Instead of instantly creating a new instance for the clothing use:

-- If an instance already exists that instance will be used, otherwise It will create a new one
local Shirt = Model:FindFirstChildOfClass("Shirt") or Instance.new("Shirt", Model)
local Pants = Model:FindFirstChildOfClass("Pants") or Instance.new("Pants", Model)

And for the templates use:

Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=8878853958"
Pants.PantsTemplate = "http://www.roblox.com/asset/?id=9575156100"
Ad

Answer this question