Why not use the Humanoid.Died event?
Humanoid.Died:Connect(function()
--fires whenever the player dies
end)
well the death animations play so i dont think thats the problem
Try to remove :GetChilden()
for i, v in pairs should automically get all childrens from the object
ServerScriptService.DropTools:7: invalid argument #1 to ‘pairs’ (table expected, got Instance)
ex dee
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.
Ah yes, :GetChildren() is not the problem
When the player equips a tool, it gets cloned into the Character. Try looping through their character for any tools. If not try their starterpack.
Yes because they are using UserInputService which is local. This can be handled on the server.
Wait, why did you link the reply?
i used humanoid:UnequipTools() before i parented the tools to game.workspace
do you know wat filtering enabled is
You should make this on Server-Side because exploiters can bypass it.
Yes, I know what Filtering Enabled is.
what do u mean by server-side, how would i detect a players death?
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)