Just do something like this.
humanoid.Died:Connect(function()
for i,v in pairs(backpack:GetChildren()) do
if v:IsA("Tool") then
v.Parent = workspace
end
end
end
Just do something like this.
humanoid.Died:Connect(function()
for i,v in pairs(backpack:GetChildren()) do
if v:IsA("Tool") then
v.Parent = workspace
end
end
end
Server-side is just a regular script, it isn’t local and you can use the Humanoid.Died event.
The script would be located in:
StarterPlayer > StarterCharacterScripts
Try using this :
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(character)
humanoid.Died:Connect(function()
for _,obj in pairs(character:GetChildren()) do
if obj:IsA("Tool") then
obj.Parent = game.Workspace
end
end
--If you want to drop objects only that are equipped delete the line under this.
for _,obj in pairs(player.Backpack:GetChildren()) do
if obj:IsA("Tool") then
obj.Parent = game.Workspace
end
end
end)
Put this all into script and put script into StarterCharacter
https://gyazo.com/de1c919099e2e6c39be7b5c1a1f0ce9e
my problem with this script is that i cant pick up the tools after i died
i made a folder for when the player dies in startercharacterscripts and inserted 2 scripts
drop tools
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local humanoid = character:WaitForChild("Humanoid")
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local Death1 = ReplicatedStorage.Animations.Death1
humanoid.Died:Connect(function()
wait(5.20)
humanoid:UnequipTools()
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 + Vector3.new(0,15,0)
end
end
end)
play death animation
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")
humanoid.Died:Connect(function()
HumanoidRootPart.Massless = true
local deathanimtrack = humanoid:LoadAnimation(Death1)
deathanimtrack:Play()
wait(2)
HumanoidRootPart.Massless = false
end)