Help with pcall :Destroy()

  1. What do you want to achieve? If you have one of the needed tools the script will destroy the corresponding tool. And wont stop the script.

  2. What is the issue? So basically, the tools get unequipped and the output prints out (“TESTDONE”) and the cooked meat gets added into the players backpack, however the tool(uncooked meat) doesnt get removed

local Part = script.Parent.Parent
local ProximityPrompt = script.Parent
local Cooked_Meat = game.ServerStorage["Cooked Meat"]



ProximityPrompt.Triggered:connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Players = game:GetService("Players")
	local humanoid = Character:WaitForChild("Humanoid")
	local backpack = Player:FindFirstChild("Backpack")
	
	
	humanoid:UnequipTools()
	local BoarMeat = backpack:FindFirstChild("Boar Meat")
    local ChickenMeat = backpack:FindFirstChild("Chicken Meat")
	wait(1)
	pcall(function()
	BoarMeat:Destroy()
	ChickenMeat:Destroy()
		
	end)
	ProximityPrompt.Enabled = false
	wait(5)
	print("TEST DONE")
	Cooked_Meat:Clone()
	Cooked_Meat.Parent = backpack
	ProximityPrompt.Enabled = true

	
	
	
	
	
end)

local Success, Err = xpcall(function()
BoarMeat:Destroy()
end, function()
error(“Found an Error”)
end)

1 Like

Thank you. This worked!

(30 chhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.