local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Death1 = ReplicatedStorage.Animations.Death1
local player = game.Players.LocalPlayer
local humanoid = player.Character:WaitForChild("Humanoid")
local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
local ToolDropOnDeath = ReplicatedStorage.RemoteEvents.ToolDropOnDeath
local deathanimtrack
humanoid.HealthChanged:Connect(function()
if humanoid.Health <= 0 then
humanoid:UnequipTools()
ToolDropOnDeath:FireServer()
HumanoidRootPart.Massless = true
deathanimtrack = humanoid:LoadAnimation(Death1)
deathanimtrack:Play()
wait(2)
HumanoidRootPart.Massless = false
end
end)
server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ToolDropOnDeath = ReplicatedStorage.RemoteEvents.ToolDropOnDeath
ToolDropOnDeath.OnServerEvent:Connect(function(player)
local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
for i,tool in pairs(player.Backpack:GetChildren()) do
if tool:IsA("Tool") and tool:FindFirstChild("Handle") then
tool.Parent = game.Workspace
tool.Handle.CFrame = HumanoidRootPart.CFrame
end
end
end)
Well, it’s better than detecting it when it changes AND you can even do this also:
-- Server script in StarterCharacter
local Character = script.Parent
local player = game.Players:GetPlayerFromCharacter(Character)
local humanoid = Character:WaitForChild("Humanoid")
local humanoidRoot = Character:WaitForChild("HumanoidRootPart")
local deathanimtrack
humanoid.Died:Connect(function()
humanoid:UnequipTools()
for I, tools in pairs(player.Backpack:GetChildren()) do
tools.Parent = workspace
end
humanoidRoot.Massless = true
deathanimtrack = humanoid:LoadAnimation(Death1) --where is this?
deathanimtrack:Play()
wait(2)
humanoidRoot.Massless = false
end)
This could be used, no remote events were necessary, quite easier.