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

Tool not replacing clothes?

Asked by 2 years ago

So I'm working on a tool that whenever its activated plays a animation then puts on the clothes, however It appears to remove the clothes and play the animation, however doesn't appear to add the clothes

script:

local tool = script.Parent
local Animation = tool.Animation
local Woosh = tool.Woosh

tool.Activated:Connect(function()
    Woosh:Play()
    local Character = tool.Parent
    local Humanoid = Character.Humanoid

    local AnimationTrack = Humanoid:LoadAnimation(Animation)
    AnimationTrack:Play()
    wait(1)
    local AttachSound = Instance.new("Sound")
    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

    AttachSound.Parent = Model
    AttachSound.Volume = 10
    AttachSound.SoundId = "rbxassetid://12221967"
    AttachSound.Looped = false
    AttachSound:Play()
    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()
    game:GetService("Debris"):AddItem(AttachSound,0.5)
end)

1 answer

Log in to vote
1
Answered by 2 years ago

[IF THIS WORKS MARK THIS ANSWER AS ACCEPTED]

The reason the clothing isn't loading is because their asset id's have not been loaded in game. The easiest way to load them is to create a shirt and pants in ReplicatedStorage with the clothingId's you want to change to.

For shirts For pants

Then change the script to:

local tool = script.Parent
local Animation = tool.Animation
local Woosh = tool.Woosh

tool.Activated:Connect(function()
    Woosh:Play()
    local Character = tool.Parent
    local Humanoid = Character.Humanoid

    local AnimationTrack = Humanoid:LoadAnimation(Animation)
    AnimationTrack:Play()
    wait(1)
    local AttachSound = Instance.new("Sound")
    local char = tool.Parent:FindFirstChild("Humanoid")
    local Model = char.Parent

    if char.Parent:FindFirstChild("Shirt") and char.Parent:FindFirstChild("Pants") then
        char.Parent.Shirt:Destroy()
        char.Parent.Pants:Destroy()
    end
    wait()
    AttachSound.Parent = Model
    AttachSound.Volume = 10
    AttachSound.SoundId = "rbxassetid://12221967"
    AttachSound.Looped = false
    AttachSound:Play()
    char.WalkSpeed = 20
    char.MaxHealth = 150
    char.Health = 150
    local shirtcopy = game.ReplicatedStorage.Shirt:Clone()
    local pantscopy = game.ReplicatedStorage.Pants:Clone()
    shirtcopy.Parent = Model
    pantscopy.Parent = Model
    tool:Destroy()
    game:GetService("Debris"):AddItem(AttachSound,0.5)
end)
Ad

Answer this question