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

I've tried again, but it won't work?

Asked by 8 years ago
local shirtTemplate = "http://www.roblox.com/asset/?id=" ..

local hatTemplate = "http://www.roblox.com/asset/?id=" ..

local pantsTemplate = "http://www.roblox.com/asset/?id=" ..

local faceID = "rbxasset://textures\\Blank.png" 

local delete_Tshirts = true

function changeClothing(p) 
    if (p.Character) then 
        local shirt = true 
        local pants = true 
        local face = true 
        if (shirtTemplate == "") then shirt = false end 
        if (hatTemplate == "") then hat = false end 
        if (pantsTemplate == "") then pants = false end 
        if (faceID == "") then face = false end 
        local S = Instance.new("Shirt") 
        S.Name = "Shirt" 
        local H = Instance.new("Hat") 
        H.Name = "Hat" 
        H.HatTemplate = hatTemplate 
        local P = Instance.new("Pants") 
        P.Name = "Pants" 
        P.PantsTemplate = pantsTemplate 
        for _,v in pairs(p.Character:GetChildren()) do 
            if (v.className == "Shirt") then 
                if (shirt) then 
                    v:remove() 
                end 
            if (v.className == "Hat") then 
                if (hat) then 
                    v:remove() 
                end 
            elseif (v.className == "Pants") then 
                if (pants) then 
                    v:remove() 
                end 
            elseif ((v.className == "Part") and (v.Name == "Torso")) then 
                if ((delete_Tshirts) and (v:findFirstChild("roblox"))) then 
                    v.roblox:remove() 
                end 
            elseif ((v.className == "Part") and (v.Name == "Head")) then 
                if ((face) and (v:findFirstChild("face"))) then 
                    v.face.Texture = faceID 
                end 
            end 
            if (shirt) then 
                S.Parent = p.Character 
            end 
            if (hat) then 
                H.Parent = p.Character 
            end 
            if (pants) then 
                P.Parent = p.Character 
            end 
        end 
        print("Changed " .. p.Name .. "'s clothing") 
    else 
        print(p.Name .. "'s character was not found; function returned") 
        return 
    end 
end 

game.Players.PlayerAdded:connect(function(p) 
    repeat wait() until p.Character 
    changeClothing(p) 
    p.Changed:connect(function(x) 
        if (x == "Character") then 
            game:service("RunService").Stepped:wait() 
            if not (p.Character) then return end 
            changeClothing(p) 
        end 
    end) 
end) 

I looked through models, and compiled what I thought would work, and I edited it for my using, but it still won't work. I just want the script to allow the player to paste the shirt/pants/hat ID into the gui, hit enter on their keyboard, and it'll put the clothing onto the character. I don't know what I'm doing wrong, so please help.

Answer this question