Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need help with my tree cutting system trying to make it so you can only carry 3 pieces of wood?

Asked by 3 years ago

Script in tool named axe

local hit = 1
local axe = script.Parent
local debounce = true
local AxeHit = false
axe.Equipped:Connect(function()
end)
axe.Activated:Connect(function()
    local human = script.Parent.Parent.Humanoid
    if debounce == true then
        if hit == 1 then
            hit = hit + 1
            local Axe1anim = human:LoadAnimation(script.Axe1)
            Axe1anim:Play()
            debounce = false
            AxeHit = true
            wait(1)
            debounce = true
         AxeHit = false
        else
            local Axe2anim = human:LoadAnimation(script.Axe2)
            hit = hit - 1
            Axe2anim:Play()
            debounce = false
            AxeHit = true
            wait(1)
            debounce = true
            AxeHit = false
            end
        end
end)
local folder = script.Parent.Parent
local count = 0
local db = true
local nameToFind = "Log"
local player = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
script.Parent.AxeHitbox.Touched:Connect(function(hit)
if hit.Parent.Name == "Tree" then
        if AxeHit == true then
            if db == true then
                db = false
                script.Parent.RemoteEvent:FireClient(player)
                print("yes")
                game.Workspace.Sounds.Chop:Play()
                hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 1
                wait(1)
                db = true
                if script.Parent.Value.Value < 3 then
                    if hit.Parent.Humanoid.Health == 0 then
                        script.Parent.Value.Value = script.Parent.Value.Value + 1
                    hit.Parent.Humanoid.Health = 4
                    hit.Anchored = false
                    game.Workspace.Sounds.TreeFall:Play()
                    local log = game.ReplicatedStorage.Log:Clone()
                        log.Parent = script.Parent.Parent
                    wait(5)
                    local Tree = game.ReplicatedStorage.Tree:Clone()
                    Tree:MoveTo(hit.Position)
                        hit.Parent:Destroy()
                    wait(5)
                        Tree.Parent = game.Workspace


                        end
                end
                end
                    end
            end
    end)

Local script it wont get to line 4

script.Parent.RemoteEvent.OnClientEvent:Connect(function()
    print("made it this far2")
    if script.Parent.Value == 3 then
    print("made it this far4")
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true
    wait(3)
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true
        end
end)

Answer this question