I'm trying to make my custom character transform when the player press e, and it will go back to its original from by pressing e again, but it kept saying: The Parent property of Leg1 is locked, current parent: NULL, new parent ---- is anything wrong here?
local KeyPressed = 0
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then -- if e is pressed one time, it will set the part listed below nil
KeyPressed = 1
L1:Destroy()
L1.Parent = nil
L2.Parent = nil
L12.Parent = nil
L22.Parent = nil
S1.Parent = nil
S2.Parent = nil
Animate.Parent = nil
Humanoid.HipHeight = 1
end
end)
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then -- if e is pressed again, it will set the part back to the character
KeyPressed = 2
L1.Parent = script.Parent
L2.Parent = script.Parent
L12.Parent = script.Parent
L22.Parent = script.Parent
S1.Parent = script.Parent
S2.Parent = script.Parent
Animate.Parent = script.Parent
Humanoid.HipHeight = 10
end
end)

2 comments
Why set it's parent to nil? There's easier ways to do this.
what's that?