Only Help if you’ve got time!
I want this script, to be as it is, but you need to Activate the Axe (Tool) before You get the Chops and the other stuff.
I don’t know how to put a ClickDetector in this script, I’m a beginner so I don’t know much!
I’ve tried tutorials and Dev Hub.
local TH = game.ReplicatedStorage.TreeHit -- Can use if you want too.
local axe = game.StarterPack.Axe
local AxeStrength = axe.AxeStrength
local head = axe.Head
local tree = script.Parent
local TreeHealth = tree.TreeHealth
local AxeName = axe.AxeName
local Active = tree.ActiveOrNot -- I added this BoolValue, which Imma use later.
local TreeMaxHealth = 25
local Multiplier
local Billboard = script.Parent.TreeHealthBar.BillboardGui
local db = false
local db_time = .5
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = plr:WaitForChild("leaderstats")
local _2x_Chops = plr:WaitForChild("GamepassStats")._2x_Chops
tree.Touched:Connect(function(hit)
if hit.Parent.Name == axe.Name then
if db then
return
end
db = true
if _2x_Chops.Value == true then
print("2x Chops")
Multiplier = 2
elseif _2x_Chops.Value == false then
print("1x Chops")
Multiplier = 1
end
wait(.9)
print("Tree got Hit by " .. AxeName.Value .. " By the player " .. plr.Name)
local TotalStrength = AxeStrength.Value * Multiplier
if AxeStrength.Value >= TreeHealth.Value then
TotalStrength = TreeHealth.Value
end
TreeHealth.Value = TreeHealth.Value - TotalStrength
leaderstats.Chops.Value = leaderstats.Chops.Value + TotalStrength
wait(db_time)
db = false
end
if TreeHealth.Value <= 0 then
Active.Value = false
wait(30)
Active.Value = true
end
end)
while true do
wait()
if Active.Value == false then
tree.Transparency = 1
tree.CanCollide = false
tree.CanTouch = false
Billboard.Enabled = false
TreeHealth.Value = TreeMaxHealth
elseif Active.Value == true then
tree.Transparency = 0
tree.CanCollide = true
tree.CanTouch = true
Billboard.Enabled = true
end
end
end)
As I said, Only help if you’ve got time!