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

Renaming a shirt/pants, can someone help?

Asked by 3 years ago
Edited 3 years ago

I have a script that change clothing, sometimes the script dont find a shirt, so the script create a new shirt on the player, and it comes with name "Clothing", and the script cant to find the shirt because the name is different, can someone help me? My script :

local ChangerPart = script.Parent
local ShirtTemplate = "http://www.roblox.com/asset/?id=1234"
local PantsTemplate = "http://www.roblox.com/asset/?id=1234

ChangerPart.Touched:Connect(function(TouchPart)
    if TouchPart and TouchPart.Parent and TouchPart.Parent:FindFirstChild("Humanoid") then
        print(TouchPart.Parent.Name ..  " - Changed clothes")
        local Character = TouchPart.Parent
        local shirt = Character:FindFirstChildOfClass("Shirt")
        local pants = Character:FindFirstChildOfClass("Pants")
        if not shirt then 
            shirt = Instance.new("Shirt", Character)
        end 
        if not pants then 
            pants = Instance.new("Pants", Character)
        end
        Character.Shirt.ShirtTemplate = ShirtTemplate
        Character.Pants.PantsTemplate = PantsTemplate
        wait(3)
    end
end)

(I got this script from a youtube tutorial, and i made some changes, and a guy helped me to make the system to create a new shirt if dont find one)

1 answer

Log in to vote
0
Answered by 3 years ago

lol hi again.

if not shirt then 
    shirt = Instance.new("Shirt", Character)
    shirt.Name = "Shirt"
end 
if not pants then 
    pants = Instance.new("Pants", Character)
    pants.Name = "Pants"
end
0
Wow, thank you soooo much!!!!!! PenguinAwesome_7 4 — 3y
Ad

Answer this question