In my current script when you click a certain block of a tree the rest falls down, How can I get it so only when you have a tool with the name "Axe" you are able to harvest the tree? I have been trying a lot of things but nothing works.
wait(2)
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character
local x = script:FindFirstChild("Wood")
local GetWood = true
function ShowProgress(tree)
if tree == 'SmallTree1' then
for i = 0,1,.01 do
WC.BG.Progress.Size = UDim2.new(i,0,1,0)
wait()
end
elseif tree == 'MediumTree' then
for i = 0,1,.005 do
WC.BG.Progress.Size = UDim2.new(i,0,1,0)
wait()
end
end
end
mouse.Button1Down:connect(function()
if mouse.Target ~= nil and mouse.Target.Parent.Name == 'SmallTree1' and GetWood == true then
local Wood = mouse.Target
if (Wood.position - char.UpperTorso.position).magnitude < 10 then
GetWood = false
WC = plr.PlayerGui.WoodChopper
WC.BG.Visible = true
ShowProgress('SmallTree1')
for i,v in pairs(Wood.Parent.Leaves:GetChildren()) do
if v:IsA('Part') then
v.Anchored = false
end
end
for i,l in pairs(Wood.Parent.Logs:GetChildren()) do
if l:IsA('Part') then
l.Anchored = false
end
end
Wood:Destroy()
WC.BG.Visible = false
GetWood = true
end
end
end)

3 comments
if plr.Backpack:FindFirstChild("Axe"), but I would note to you that since this is a localscript the stuff you are doing will not replicate (i.e.: Unanchoring a part). You need to use remote events
Do you know what this is? I cant open Roblox Studio, it says: Team Create reconnect fail. Unable to fetch game settings data.
No idea