Begin Coding
Copy the code in the image above into your ToolScript. You will start on line 13.
Check if Item is Harvestable Cont.:
After a player harvests the item, the item should disappear and CanHarvest set to false for a short time before becoming harvestable again.
By making the value of canHarvest false as soon as players harvest the item, the script won’t give more than one item per tool hit.
partTouched.Transparency = 1
partTouched.CanCollide = false
Changing the transparency to 1 will make the cupcake invisible and making CanCollide false means the player can walk through it. Letting players walk through the object stops having “invisible” cupcakes that block a player.
If you want to get a value from an IntValue object or BoolValue object, you need to use .Value at the end.
Playtesting
Playtest your game and press the number 1 to pull out your spoon. Now try to collect your item with your spoon by clicking on it.