My Model DeadBody wont spawn in the right place?
01 | DedScript = game.Workspace.Human.DeadBody |
02 | ded = game.ReplicatedStorage.Dead:Clone() |
03 | chest = game.Workspace.Human.Torso |
04 | Heart = Instance.new( "Part" ) |
06 | local w = Instance.new( 'Weld' ) |
09 | w.C 0 = CFrame.new( 0 , 0 , 0 )*CFrame.Angles( 0 , 0 , 0 ) |
12 | if DedScript.Parent.Humanoid.Health< 1 then |
14 | Heart.Parent = workspace |
15 | Heart.Transparency = 0 |
17 | ded.Parent = workspace |
19 | primary_part = ded.Torso |
20 | ded.PrimaryPart = primary_part |
23 | primary_part.Anchored = true |
25 | local part = ded [ "Part" .. index ] |
26 | local weld = Instance.new( "Weld" ) |
28 | weld.Part 0 = primary_part |
30 | weld.C 1 = part.CFrame:toObjectSpace(primary_part.CFrame) |
31 | weld.Parent = primary_part |
34 | local w 2 = Instance.new( 'Weld' ) |
36 | w 2. Part 1 = primary_part |
37 | w 2. C 0 = CFrame.new( 0 , 0 , 0 )*CFrame.Angles( 0 , 0 , 0 ) |
38 | w 2. Parent = primary_part |
40 | ded:SetPrimaryPartCFrame(Heart * CFrame.new( 0 , 0 , 0 )) |
I have an NPC called Human in workspace. When it dies the part name "Heart" should spawn at its torso that I've named "Chest". Then a Model Dead Body that I've put in Replicated Storage should be cloned into workspace (Ive named the clone "ded") and placed where the Heart is. However it doesnt seem to work. It gives me this error on line 40
"Workspace.Human.Dead:43: bad argument #1 to '?' (CFrame expected, got userdata)
Script 'Workspace.Human.DeadBody', Line 40
Stack End"
DeadBody is the name of the script. Please help me with this.