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

During Character Customization, Hat Added But Won't Remove?

Asked by 6 years ago

I am creating a neat little project that is very ambitious for a poor scripter like myself. I am writing code for a character customization prompt that allows for the use of hats to be placed upon the character's head (whom is using an R15 rig.) The hat places on just fine, however, when I click the button again and the script checks to see if the hair is on, the hair just stays on and doesn't get removed. Here's the block of code I used:

Character = game.Workspace.IntroSequence.Character
MyCharacter = game.Players.LocalPlayer.Character
x = game.Lighting["rickshair"]:clone()

script.Parent.MouseButton1Down:connect(function()
    if MyCharacter:FindFirstChild("rickshair") ~= nil then
        Character["rickshair"]:destroy()
        MyCharacter["rickshair"]:destroy()
        x:clone()

    end

    if MyCharacter:FindFirstChild("rickshair")== nil then
    x.Parent = Character
        x.Parent = Character
    x.Parent = MyCharacter
        x.Parent = MyCharacter
    end 
end)

You may notice the "Character" and "MyCharacter" definitions. This is because in the character customization screen I use a different model than the actual player, but place accessories on both at the same time. Hopefully that concludes any confusion.

0
wew so much deprecated stuff yay hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Character = game.Workspace.IntroSequence.Character
MyCharacter = game.Players.LocalPlayer.Character
x = game.Lighting["rickshair"]:Clone()

script.Parent.MouseButton1Down:Connect(function()
    if MyCharacter:FindFirstChild("rickshair") ~= nil then
        Character["rickshair"]:Destroy()
        MyCharacter["rickshair"]:Destroy()
        x:clone()

    end

    if MyCharacter:FindFirstChild("rickshair")== nil then
    x.Parent = Character
        x.Parent = Character
    x.Parent = MyCharacter
        x.Parent = MyCharacter
    end 
end)


0
@hiimgoodpack lmao k IfIWasntSoSwag 98 — 6y
0
the only thing I see here is some corrections in my scripting. this.. doesn't really help. aquadrious 53 — 6y
0
@SupahZekrom Koolio IfIWasntSoSwag 98 — 6y
Ad

Answer this question