Death Effect (BodyPart Floating)

I am trying to make an effect where the body parts float upwards upon death. Right now I am just trying to do it with one body part. I am somewhat new to scripting, and this probably isn’t even close. But just let me know how I can change it or some terms to research for this particular script!

local function onDeath(player)
local position = player.Character.LeftUpperArm.Position
local hum = player.Character:FindFirstChild(‘Humanoid’)

if hum.Health == 0 then
	for i,v in pairs(position) do
	position = Vector3.new(position + 100,100,100)
	end
end

end

game.Players.PlayerAdded:Connect(function(onDeath)

2 Likes

You should either use Velocity or BodyMovers such as BodyForce or BodyVelocity.
If you go with Velocity you need to use the Stepped event to sync with physics. BodyMovers are the easiest option and these are what I’d suggest.

5 Likes

Okay, I’ll give it a go. Thanks!

1 Like

you can also use tweenservice:

local parts = player.Character:GetChildren()
local hum = player.Character:FindFirstChild(‘Humanoid’)
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

local function onDeath(player)
if hum.Health == 0 then
	for i,v in pairs(parts) do
        if v:IsA("Mesh") or v:IsA("Accessory") then
	        local Tween = ts:Create(v, ti, {Position = Vector3.new(v.Position.X, v.Position.Y + 2.2, v.Position.Z)}) -- Goes Up
			Tween:Play()
        end
	end
end

game.Players.PlayerAdded:Connect(function(onDeath)

this will move the WHOLE player

5 Likes

Didn’t think of that. For some reason I was under the impression TweenService could only be used for UI.

Yeah, that’s what I thought at first. Some people don’t know that, and use for I loops which would produce glitchy results

1 Like

I should know this, but what does the V represent in the loop statement?

v is the children of the character. It is basically a variable form of every child of the character.

Thank you! I was just unsure for this specific code.

You could use a floating animation, once they die.

2 Likes