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

How to receive parts that is nil back?

Asked by 6 years ago

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?

01local KeyPressed = 0
02 
03game:GetService("UserInputService").InputBegan:connect(function(input)
04    if input.KeyCode == Enum.KeyCode.E then -- if e is pressed one time, it will set the part listed below nil
05    KeyPressed = 1
06       L1:Destroy()
07L1.Parent = nil
08L2.Parent = nil
09L12.Parent = nil
10L22.Parent = nil
11S1.Parent = nil
12S2.Parent = nil
13Animate.Parent = nil
14Humanoid.HipHeight = 1
15   end
View all 30 lines...
0
Why set it's parent to nil? There's easier ways to do this. oftenz 367 — 6y
0
what's that? MArzalAlBuchariZ 33 — 6y

1 answer

Log in to vote
1
Answered by
aschepler 135
6 years ago

Destroy can't be undone, and one of the things it does is lock the Parent property so it can't be put back in the game.

So take out your L1:Destroy() line. The parts setting Parent properties to nil is enough to get the parts temporarily out of the game.

Ad

Answer this question