I have a chest and when someone clicks on it they get it inside there inventory. I can't figure out a working script to have it drop on death of player. This is what I have been trying to do.

workspace.DescendantAdded:connect(function(a) if game.Players:FindFirstChild(a.Name) ~= nil then local died = false a.Humanoid.Died:connect(function() if died == false then died = true print'died' local cf = a.Torso.CFrame local p = game.Players:FindFirstChild(a.Name).Backpack:GetChildren() for i= 1, #p do if p[i].ClassName == 'Tool' and p[i]:FindFirstChild'Handle' ~= nil and a:FindFirstChild(p[i].Name) == nil then p[i].Parent = workspace p[i].Handle.CFrame = cf p[i].Handle.CanCollide = true end end

		p = a:GetChildren() 
		for i= 1, #p do 
		if p[i].ClassName == 'Hat' then p[i].Parent = workspace end
		if p[i].ClassName == 'Tool' then p[i].Parent = workspace p[i].Handle.CanCollide = true end
		end
		
		died = false
		end
		
	end)
end

end)

1 comment

0

Where is your attempt at this?