How can I get :Destroy() to delete the tool while equipping it?
Asked by
4 years ago Edited 4 years ago
I am making a tool that is raw beef and I was gonna make it so after a certain amount of bites, the tool gets destroyed. I am destroying on the server, and I did connect with remotes. The tool does get destroyed, but after I unequip the tool
04 | local tool = script.Parent |
06 | local foodHandler = game:GetService( 'ReplicatedStorage' ):WaitForChild( 'foodHandler' ) |
07 | local foodItem = tool.Name |
09 | tool.Activated:Connect( function () |
17 | foodHandler:FireServer(foodItem) |
25 | local foodHandler = game:GetService( 'ReplicatedStorage' ):WaitForChild( 'foodHandler' ) |
27 | local function removeFood(player, foodItem) |
28 | player.Backpack:WaitForChild(foodItem):Destroy() |
30 | foodHandler.OnServerEvent:Connect(removeFood) |
everything else in the script works. If you can help me then tysm!