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

How can people change their clothes by putting in a Catalog ID instead of the Template ID?

Asked by 7 years ago

Hello fellow ROBLOXians,

Today I have a question about a script I made for a GUI in my RPG game.

I notice that a lot of visitors do not know that for changing clothes in a GUI, you need to put in the ID of the Shirt/Pants template, so they just put in the Catalog ID.

I have seen in some games that by just putting in the ID of the Catalog Product (The ID where the shirt or pants can be bought)

How could I make my script make people change clothes by putting in the Catalog ID instead of the template, here is the script:

local prefix = "http://www.roblox.com/asset/?id="
local player = script.Parent.Parent.Parent.Parent.Parent
local shirtbox = script.Parent.Parent:FindFirstChild("shirt")
local pantsbox = script.Parent.Parent:FindFirstChild("pants")
debounce = false

function onclck()
    if debounce == false then
    debounce = true

    local shirt = player.Character:FindFirstChild("Shirt")
    local pants = player.Character:FindFirstChild("Pants")
    if shirtbox.Text ~= "Shirt ID" then
        if shirt ~= nil then
        shirt:Remove()
        local clon = script.Parent:FindFirstChild("Shirt"):Clone()
        clon.Parent = player.Character
        clon.ShirtTemplate = prefix .. shirtbox.Text
        else
            local clon = script.Parent:FindFirstChild("Shirt"):Clone()
            clon.Parent = player.Character
            clon.ShirtTemplate = prefix .. shirtbox.Text
        end
    end
    if pantsbox.Text ~= "Pants ID" then
        if pants ~= nil then
        pants:Remove()
        local clon = script.Parent:FindFirstChild("Pants"):Clone()
        clon.Parent = player.Character
        clon.PantsTemplate = prefix .. pantsbox.Text
        else
            local clon = script.Parent:FindFirstChild("Pants"):Clone()
            clon.Parent = player.Character
            clon.PantsTemplate = prefix .. pantsbox.Text
        end
    end

    wait(0.5)
    debounce = false
    end
end

script.Parent.MouseButton1Click:connect(onclck)

Answer this question