Sound of my tool not syncing

Hi,

So I made an axe that cuts down a tree. But the sound is not syncing. The sound plays when the axe touches the tree instead of when it’s activated. Which is not what I want.

Also, tool has an animation where it swings back and then hits the tree. This is like maybe a 0.5 sec of wait.

Any help?

local TweenSerivce = game:GetService("TweenService")
local Players = game:GetService("Players")

local tool = script.Parent
local handle = tool.Handle
local sound = script.Parent.Axesound

local stump

local deBounce = true
local treeChops = 0

local function createTween(stump, goals, reverses)

    local tweenInfo = TweenInfo.new(
        0.1,
        Enum.EasingStyle.Bounce,
        Enum.EasingDirection.InOut,
        0,
        reverses,
        0
    )

    local tween = TweenSerivce:Create(stump, tweenInfo, goals)
    wait(0.8)
    tween:Play()

end

local function findStump(hit)

    if hit.Parent.ClassName == "Model" then
        stump = hit.Parent:FindFirstChild("Stump")
        wait(0.8)
        sound:Play() 
        wait(1)
    end

end

local function respawnTree(tree)

    wait(3)
    tree.Transparency = 0
    tree.CanCollide = false

end

local function chopTree()

    if deBounce then

        deBounce = false

        if stump then

            local humanoidRootPart = tool.Parent:FindFirstChild("HumanoidRootPart")

            if (handle.Position - humanoidRootPart.Position).Magnitude < 5 and stump.Transparency == 0 then

                treeChops += 1

                local goals = {Position = stump.Position + Vector3.new(0, 2, 0)}
                createTween(stump, goals, true)

                if treeChops >= 3 then

                    treeChops = 0
                    stump.Transparency = 1
                    stump.CanCollide = false

                    local leaderstats = Players:GetPlayerFromCharacter(tool.Parent):FindFirstChild("leaderstats")

                    if leaderstats then
                        local wood = leaderstats:FindFirstChild("Wood")
                        wood.Value += 5
                    end

                    respawnTree(stump)

                end
            end
        end
    end

    deBounce = true

end

handle.Touched:Connect(findStump)
tool.Activated:Connect(chopTree)

Then i’d add the sound effect play below this line, it should work.

if (handle.Position - humanoidRootPart.Position).Magnitude < 5 and stump.Transparency == 0 then

I’ve done it, but it’s still not working.

I get this issue delay

Well, I don’t see where the sound is located is in the script.

image
here :slight_smile:

I’d use a debris and just make a new sound everytime you activate it.

here in the ‘findStump’ function

so basically like this.

local Debris = game:GetService("Debris")
local Sound = Axesound:Clone()
Sound.Parent = ??
Sound:Play()

Debris:Additem(Sound, 1)

I’m sorry, a Debris? What exactly will that do?

A debris just allows something to be temporary without haven’t to call :Destroy and we can specify how long