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

How do I make the dead body stay?

Asked by 5 years ago

I want to make like a spectating system and I want the player's body to stay where they died so they can spectate and their body will stay.

I tried getting their character position when they're dead, Cloning the character and doing if their character position is not the position that they were dead it makes the clone appear and that didn't work.

I would really appreciate it if you help me and tell me the script for it or minimum the method of doing that.

Thanks, MajinBluee

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago
local Character= game.Players.LocalPlayer.Character
local humanoid = character:WaitForChild("Humanoid")

local clone = character:Clone()

-------------------------------------------------------------------------------

local torsoPos = nil

function ANCHOR(character, state)
    if character ~= nil then
        for _, v in pairs(character:GetChildren()) do 
            if v:IsA("BasePart") then 
                v.Anchored = true 
            end
        end
    end
end

humanoid.Died:connect(function()
    --anchor character--
    ANCHOR(Character, true) --prevent character from flinging

    --get torso cframe--
    if Character:FindFirstChild("Torso") then 
        torsoPos = Character.Torso.CFrame
    end
    ANCHOR(Character, false)

    --create posPart--
    local posPart = Instance.new("Part")
    posPart.Anchored = true 
    posPart.Size = Vector3.new(.2, .2, .2)
    posPart.CFrame = torsoPos

    --set clone's position--
    if clone ~= nil and clone:FindFirstChild("Torso") then
        ANCHOR(clone, true)
        clone.Parent = workspace
        clone:FindFirstChild("Torso").CFrame = posPart.CFrame
        wait(.1)
        ANCHOR(clone, false)
    end
end)
0
edit the code if you have a modified ragdoll awesomeipod 607 — 5y
0
Thanks bro! MajinBluee 80 — 5y
0
k MajinBluee 80 — 5y
0
Why did you give him free code when he didn’t even try? Downvoted. User#19524 175 — 5y
View all comments (6 more)
2
Wym? He clearly stated. "I tried getting their character position when they're dead, Cloning the character and doing if their character position is not the position that they were dead it makes the clone appear and that didn't work." awesomeipod 607 — 5y
0
How do you know he isn’t lying? User#19524 175 — 5y
0
dude why are you so mean to others? mixgingengerina10 223 — 5y
0
It’s not being mean. I’m not being aggressive, I’m just pointing out that he may be lying about trying, to get free code. User#19524 175 — 5y
0
Which literally doesn't even matter, because somebody providing code is their own prerogative, and ultimately is the point of this website. fredfishy 833 — 5y
0
Stop arguing, I'm not trying to get free codes. MajinBluee 80 — 5y
Ad

Answer this question