How to make a choppable tree!

This tutorial will show you how to make a tree that can be cut down

by giantjdd

Author Avatar

To begin you need a tree

img|80x90

This is my tree (I made it in like 2 seconds)

After you have a tree, we need to put a click detector on the trunk, and add a script to the trees model aswell

img|80x60

This is my trees hierarchy now So now we actually code the tree, so open the script and lets begin

local tree = script.Parent
local trunk = script.Parent.trunk
local leaves = script.Parent.leaves
local clickDetector = trunk.ClickDetector
local health = 5

first we declared all of our variables for later use you can change the health variable to suit how many clicks you would like the tree to take to chop down

clickDetector.MouseClick:Connect(function(clicked)
    health = health - 1         -- remove 1 health
    if health == 0 then         -- check if health is 0
        trunk:Destroy()         -- destroy the trunk
        leaves.Anchored = false -- makes the leaves fall for dramatic effect
        wait(3)                 -- wait 3 seconds
        tree:Destroy()          -- destroy the trees model
    end
end)

thats all you need, then you have a cut downable tree! its also very easy to add onto it!