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
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.
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)