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

Why doesn't this script work?

Asked by 9 years ago

This is a script inside a textbutton.For some reasons it doesn't work nor does it give me any errors.It should change my Shirt and Pants.

Char = script.Parent.Parent.Parent.Parent.Character
sh = Char.Shirt
pa = Char.Pants
st = sh.ShirtTemplate
pt = pa.PantsTemplate


function onClick(mouse)
        if Char:FindFIrstChild("Shirt") then
            Char.Shirt:Destroy()
        end
        if Char:FindFIrstChild("Pants") then
            Char.Pants:Destroy()
        end
        s = Instance.new("Shirt", Char)
        s.ShirtTemplate = "http://www.roblox.com/asset/?id=255758532"
        p = Instance.new("Pants", Char)
        p.PantsTemplate = "http://www.roblox.com/asset/?id=255758581"
        script.Parent.Text = "Wear Off"
end
script.Parent.MouseButton1Click:connect(onClick)

1 answer

Log in to vote
0
Answered by
KenzaXI 166
9 years ago

Sometimes Char takes a bit to load, so do this:

Char = script.Parent.Parent.Parent.Parent.Character
repeat wait() until Char
sh = Char.Shirt
pa = Char.Pants
st = sh.ShirtTemplate
pt = pa.PantsTemplate


function onClick(mouse)
        if Char:FindFIrstChild("Shirt") then
            Char.Shirt:Destroy()
        end
        if Char:FindFIrstChild("Pants") then
            Char.Pants:Destroy()
        end
        s = Instance.new("Shirt", Char)
        s.ShirtTemplate = "http://www.roblox.com/asset/?id=255758532"
        p = Instance.new("Pants", Char)
        p.PantsTemplate = "http://www.roblox.com/asset/?id=255758581"
        script.Parent.Text = "Wear Off"
end
script.Parent.MouseButton1Click:connect(onClick)


0
FindFIrstChild is not a valid member of Model brokenrares 48 — 9y
0
"FindFIrstChild" You typed it in wrong, It's "FindFirstChild" KenzaXI 166 — 9y
Ad

Answer this question