I have a big mess of code of a pot that shatters into pieces when damaged enough and I get this error:
16:00:53.380 - The Parent property of Shatter is locked, current parent: NULL, new parent NPC 16:00:53.381 - Script 'Workspace.NPC.PotScript', Line 86
I made as a model so it will be easier to understand: http://www.roblox.com/plz-halp-meh-plez-item?id=280487754
I have seen some people ask the same question but the answers don't help in my case.
Here is the code:
local i = 1 script.Parent.Pot.Anchored = true script.Parent.Humanoid.MaxHealth = math.huge script.Parent.Head.Transparency = 1 script.Parent.Torso.Transparency = 1 for c = 1, 37 do local sha=script.Parent.Shatter["a"..c] sha.CanCollide=true sha.Transparency=1 end backup=script.Parent.Shatter model = backup:clone() px = script.Parent.Pot.CFrame.X py = script.Parent.Pot.CFrame.Y pz = script.Parent.Pot.CFrame.Z ny = pz + 10000 function killpot() for a = 1, 37 do script.Parent.Head.CFrame = CFrame.new(px, ny, pz) * CFrame.Angles(0, math.pi, 0) script.Parent.Torso.CFrame = CFrame.new(px, ny, pz) * CFrame.Angles(0, math.pi, 0) script.Parent.Pot.CFrame = CFrame.new(px, ny, pz) * CFrame.Angles(0, math.pi, 0) local shat=script.Parent.Shatter["a"..a] shat.Transparency=0 shat.Anchored=false end wait(1.5) for g = 1, 37 do local shatte=script.Parent.Shatter["a"..g] shatte.Anchored=true end for b = 1, 37 do local shatt=script.Parent.Shatter["a"..b] wait(0.01) shatt.Transparency=0.1 wait(0.01) shatt.Transparency=0.2 wait(0.01) shatt.Transparency=0.3 wait(0.01) shatt.Transparency=0.4 wait(0.01) shatt.Transparency=0.5 wait(0.01) shatt.Transparency=0.6 wait(0.01) shatt.Transparency=0.7 wait(0.01) shatt.Transparency=0.8 wait(0.01) shatt.Transparency=0.9 wait(0.01) shatt.Transparency=1 wait(0.01) end end local i=1 while i < 10 do local i = 1 wait(0.1) if script.Parent.Humanoid.Health < 50 then script.Parent.Humanoid.Health = math.huge script.Parent.Shatter.a37.Sound:Play() killpot() script.Parent.Shatter:Destroy() print"wait 10" wait(1) model.Name = "Shatter" model.Parent = script.Parent --This is line the error appears script.Parent.Pot.CanCollide = true script.Parent.Pot.Transparency = 0 script.Parent.Humanoid.Health = 100 script.Parent.Head.CFrame = CFrame.new(px, py, pz) * CFrame.Angles(0, math.pi, 0) script.Parent.Torso.CFrame = CFrame.new(px, py, pz) * CFrame.Angles(0, math.pi, 0) script.Parent.Pot.CFrame = CFrame.new(px, py, pz) * CFrame.Angles(0, math.pi, 0) end end
Sorry for it being such a mess I am a beginner at scripting.