Can anyone send me a code that clears your starterpack when you die? I'm making a game but it breaks whenever you hold out an item while you're dead.
Hope this works. Put this script in starterCharacter so it gets parented to the character even when you respawn
Put this in a script not a local script.
local Character = script.Parent local Player = game.Players:GetPlayerFromCharacter(Character) if Player then -- Make sure the script that is running is inside the Character local Humanoid = Character:WaitForChild("Humanoid") Humanoid.Died:Connect(function(Character) -- This runs as soon as someone dies -- Remove the tools that are unequipped for _, Tool in pairs(Player.Backpack:GetChildren()) do if Tool:IsA("Tool") then Tool:Destroy() end end -- Remove the tools that are equipped for _, Tool in pairs(Character:GetChildren()) do if Tool:IsA("Tool") then Tool:Destroy() end end end) end
Hope this works for you :)
local Player = game.Players.LocalPlayer local Character = Player.CharacterAdded:Wait() Character:WaitForChild("Humanoid").HealthChanged:Connect(function(health) if health <= 0 then for _,v in pairs(Player.StarterGear:GetChildren()) do v:Destroy() end end end)