Tree cutting system with axe

Hello, Im creating a tree that you can cut with an axe tool or without the axe.
The tree works using a ProximityPrompt, the tree works fine but the axe doesnt.
here are the scripts

Axe Equipped Script (doesnt work)
local Axe = "WoodenAxe"
local Player = game.Players.LocalPlayer.Backpack

script.Parent.MouseButton1Click:Connect(function()
	if Player:FindFirstChild(Axe) then
		Player.Axe.Equipped:Connect(function()
			script.Parent.Wood.GetWood.HoldDuration = 2
		end) 
		Player.Axe.Unequipped:Connect(function()
			script.Parent.Wood.GetWood.HoldDuration = 2
		end) 
	end
end)
Main (Works)
local tool = game.ReplicatedStorage.Wood
local GetWood = script.Parent.Wood.GetWood
local Plant = script.Parent.Dirt.PlantTree


GetWood.Triggered:Connect(function(Plr)
	local backpack = Plr:WaitForChild("Backpack")
	tool:Clone().Parent = backpack
	script.Parent.Wood.Transparency = 1
	script.Parent.Wood.CanCollide = false
	script.Parent.Leaves.Transparency = 1
	script.Parent.Leaves.CanCollide = false
	script.Parent.Dirt.Transparency = 0
	GetWood.Enabled = false
	Plant.Enabled = true
end)

Plant.Triggered:Connect(function()
	Plant.Enabled = false
	wait(10)
	script.Parent.Wood.Transparency = 0
	script.Parent.Wood.CanCollide = true
	script.Parent.Leaves.Transparency = 0
	script.Parent.Leaves.CanCollide = true
	script.Parent.Dirt.Transparency = 1
	GetWood.Enabled = true
end)

I want to make it so when the axe tool is equipped then the proximityPromte hold duration is less but when the tool is unequipped it goes back to normal hold duration

This is quite an odd approach, reading the equipped script it seems you are deciding to have code exclusively for the axe, not contained in the axe? If you parent the localscript in the axe you are aware it should still run right

the equipped script is in the tree as a local script and not the axe, its because i want to have multiple trees you can cut with the axe

image

Oh no no no, why would you have a separate local script for each tree? just have a script in the axe that handles everything.

How can i do that, I want to put more than one tree in the map

–My idea

  • Each tree is a model w/ all ur parts for ur tree e.t.c and has a prox prompt

  • The player has a local script running in their playerscripts that listens for when the prox prompts are fired and fires a remote event

  • Main script in ServerScriptService listens for when fired, checks which axes are equipped and if they are even close enough to cut down the tree e.t.c and then cuts the tree for you

1 Like