local tool = script.Parent
local CrackingTheTreePart = Instance.new("Part")
local player = game.Players
local plr = player.Localplayer
local mouse = plr:GetMouse()
local firstattack = true
local AxeDamage = tool:WaitForChild("AxeDetails").AxeDamage
local TreeAttackSizePlus = 1 / AxeDamage.Value
local mainrangefromtrees = 50
tool.Equipped:Connect(function()
mainrangefromtrees = 50
mouse.Button1Down:Connect(function()
local Area1Trees = game.Workspace.Area1Trees.NormalTree
coroutine.wrap(function()
for a,b in pairs(Area1Trees:GetChildren()) do
local distarea1tree = b
if mainrangefromtrees > (distarea1tree.Position - tool.Handle.Position).magnitude then
if mouse.Target == b then
if firstattack == false then
CrackingTheTreePart.Size = Vector3.new(TreeAttackSizePlus+.1,.2,1.4)
end
if firstattack == true then
CrackingTheTreePart.Parent = workspace
CrackingTheTreePart.Anchored = true
CrackingTheTreePart.CFrame = b.CFrame * CFrame.new(0,2,0)
CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4)
firstattack = false
end
end
end
end
end)()
end)
end)
tool.Unequipped:Connect(function()
mainrangefromtrees = 0
end)
Problem: When i click tree this script works:
-
if firstattack == true then CrackingTheTreePart.Parent = workspace CrackingTheTreePart.Anchored = true CrackingTheTreePart.CFrame = b.CFrame * CFrame.new(0,2,0) CrackingTheTreePart.Size = Vector3.new(.1, .2, 1.4) firstattack = false end
and second click:
-
if firstattack == false then CrackingTheTreePart.Size = Vector3.new(TreeAttackSizePlus+.1,.2,1.4) end
and when third click nothing