How to make a an axe work with Proximity Prompt?

Im trying to make an axe work with proximity prompt,

How this works :
I have made a tree in roblox studio, When you trigger the proximity prompt it gives you a tool called wood, the tree goes to replicated storage and then back to workspace after a few seconds, you can get stone to make an axe and when you have the axe, I want to make the tree cutting become faster, Here is 2 scripts I made but none worked

script 1

local Tree = game.Workspace.Trees.GroupOfTrees.Tree.Wood.ProximityPrompt

script.Parent.Equipped:Connect(function()
	Tree.Triggered:Connect(function()
		Tree.HoldDuration = 5
		if script.Parent.Unequipped then
			Tree.HoldDuration = 10
		end
	end)
end)

script 2

local Tree = game.Workspace.Trees.GroupOfTrees.Tree.Wood.ProximityPrompt

if script.Parent.Equipped and Tree.Triggered then
	Tree.HoldDuration = 5
	if script.Parent.Unequipped and Tree.Triggered then
		Tree.HoldDuration = 10
	end
end

the scripts are in the tool, and the tool is in replicated storage, when you craft it it clones and goes to the player inventory.

How do I make this work?

Unequipped would always be there since it’s a event not a boolean, and disconnect the event so the player can’t continue cutting.

local Tree = game.Workspace.Trees.GroupOfTrees.Tree.Wood.ProximityPrompt
local connection

script.Parent.Equipped:Connect(function()
	connection = Tree.Triggered:Connect(function()
		Tree.HoldDuration = 5
	end)
end)

script.Parent.Unequipped:Connect(function()
    Tree.HoldDuration = 10
    connection:Disconnect()
end)
2 Likes

You wrote local connection, what does it do?

That defines a variable which is nil, whenever the tool is equipped that variable will be set to the connection.

1 Like