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

How do I make this Try Button script work and fix the error?

Asked by 9 years ago

This is the script from BlueTaslem (thank you). When I used it with all the explanation he gave me. I mean A LOT of explanation, it gave an error in this script. I am sorry if I am being stupid here. This is the script that BlueTaslem answered:

function onClicked(player)
    local character = player.Character
    local clothing = character:GetChildren()
    local storage = Instance.new("Model")
    for _, cloth in pairs(clothing) do
        if cloth:IsA("Clothing") then
            cloth.Parent = storage
        end
    end
    wait()
    local newShirt = script.Parent.Parent.Parent.Clothes.Shirt:clone()
    local newPants = script.Parent.Parent.Parent.Clothes.Pants:clone()
    newShirt.Parent = character
    newPants.Parent = character
    wait(5)
    newShirt:Destroy()
    newPants:Destroy()
    for _, cloth in pairs(storage:GetChildren()) do
        cloth.Parent = character
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked) 


function moveClothes(from, to)
    for _, child in pairs(from:GetChildren()) do
        if child:IsA("Clothing") then
            child.Parent = to
        end
    end
end

function onClicked(player)
    local character = player.Character
    local clothing = character:GetChildren()
    local storage = Instance.new("Model")
    moveClothes(character, storage); -- Put original clothes safely away
    wait()
    moveClothes(script.Parent.Parent.Parent.Clothes:Clone(), character)
    -- Get a copy of the staged clothes, put them in the character
    wait(5)
    moveClothes(character, nil) -- Delete the show clothes
    moveClothes(storage, character) -- Put original clothes back
end

script.Parent.ClickDetector.MouseClick:connect(onClicked) 

-- Shorter (by 1/3)
-- Simpler (no loops, no ifs)
-- Clearer and more correct

This is the error:

21:44:52.770 - Clothes is not a valid member of Model
21:44:52.772 - Script 'Workspace.Man.TryButton.Part.Script', Line 11
21:44:52.772 - Stack End

This is the previous question that was answered: https://scriptinghelpers.org/questions/15180/what-is-wrong-with-this-script

0
PLease answer this. I know I already did, but I got an error to User#5689 -1 — 9y

Answer this question