I have an animation, or well, a code that SHOULD run when the tool is activated, but the first print statement doesn’t even run, and I don’t know why.
local plr = game:GetService("Players").LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Mouse = plr:GetMouse()
local Tool = script.Parent
local anim = Tool:WaitForChild("shovelAttack")
local attack1 = Tool:WaitForChild("HurtPart"):WaitForChild("AttackScript1")
local attack2 = Tool:WaitForChild("HurtPart"):WaitForChild("AttackScript2")
local values = {}
local attackEvent1 = game:GetService("ReplicatedStorage"):WaitForChild("Attack1Shovel")
local attackEvent2 = game:GetService("ReplicatedStorage"):WaitForChild("Attack2Shovel")
local DattackEvent1 = game:GetService("ReplicatedStorage"):WaitForChild("attack1")
local swingSound1 = Tool:WaitForChild("HurtPart"):WaitForChild("SwingSound")
local swingSound2 = Tool:WaitForChild("HurtPart"):WaitForChild("SwingSound2")
local db = false
-- EVERYTHING HAPPENS HERE
Tool.Activated:Connect(function()
print("activated") -- this DOESN'T run
local animator = Char.Humanoid:FindFirstChildOfClass("Animator")
if db == false then
db = true
if animator then
local Attack = animator:LoadAnimation(anim)
Attack:Play()
swingSound1:Play()
Attack.KeyframeReached:Connect(function(Attack1Frame)
if not values.Button1 then
Attack:Stop()
else
print("event1 fired")
attackEvent1:FireServer(attack1)
end
end)
Attack.KeyframeReached:Connect(function(Attack2Frame)
if not values.Button1 then
Attack:Stop()
DattackEvent1:FireServer(attack1)
else
print("event2 fired")
attackEvent2:FireServer(attack2)
swingSound2:Play()
end
end)
end
task.wait(1.75)
db = false
end
end)
Mouse.Button1Down:Connect(function(input, gameProcessed)
if gameProcessed then return end
values.Button1 = true
end)
Mouse.Button1Up:Connect(function(input, gameProcessed)
if gameProcessed then return end
values.Button1 = false
end)