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

My Model DeadBody wont spawn in the right place?

Asked by
neoG457 315 Moderation Voter
9 years ago
DedScript = game.Workspace.Human.DeadBody
ded = game.ReplicatedStorage.Dead:Clone()
chest = game.Workspace.Human.Torso
Heart = Instance.new("Part")

local w = Instance.new('Weld')
    w.Part0 = Heart
    w.Part1 = chest
    w.C0 = CFrame.new(0, 0, 0)*CFrame.Angles(0 , 0, 0)
    w.Parent = chest

if DedScript.Parent.Humanoid.Health<1 then

    Heart.Parent = workspace
    Heart.Transparency = 0

    ded.Parent = workspace

    primary_part = ded.Torso
    ded.PrimaryPart = primary_part


    primary_part.Anchored = true
    for index = 1, 8 do
local part = ded["Part" .. index] 
local weld = Instance.new("Weld")

        weld.Part0 = primary_part
        weld.Part1 = part
        weld.C1 = part.CFrame:toObjectSpace(primary_part.CFrame)
        weld.Parent = primary_part
        part.Anchored = true    

local w2 = Instance.new('Weld')
        w2.Part0 = Heart
        w2.Part1 = primary_part
        w2.C0 = CFrame.new(0, 0, 0)*CFrame.Angles(0 , 0, 0)
        w2.Parent = primary_part

        ded:SetPrimaryPartCFrame(Heart * CFrame.new(0, 0, 0))


    end

end

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.

0
Is ded in workspace? woodengop 1134 — 9y
0
Yes neoG457 315 — 9y

1 answer

Log in to vote
3
Answered by 9 years ago

Your error is on line 40, heart is a object not a CFrame. All you need to do is change it to this

ded:SetPrimaryPartCFrame(Heart.CFrame * CFrame.new(0, 0, 0)) --see now we are getting the CFrame of the heart
0
Thanks. neoG457 315 — 9y
Ad

Answer this question