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)