So I need to have the animation defined before the animation actually plays. When I try to define with script.Parent.Parent.Humanoid it returns with a error. Any ideas
--UTILLITY__
local tool = script.Parent
local canhit = false
local debounce = false
local humanoid = tool.Parent.Parent.Humanoid
--MODIFIERS--
local Damage = 10
local waittime = 7
local fling = 0
--ANIMATION--
local animloop = 1
local anim1 = script.Parent.anim1
local anim2 = script.Parent.anim2
local animation2 = humanoid:LoadAnimation(anim2)
local animation1 = humanoid:LoadAnimation(anim1)
script.Parent.Activated:Connect(function()
if debounce == false then
--animation loop
if animloop == 1 then
animloop = 2
animation2:Play()
else
animloop = 1
animation1:Play()
end
--Debounce
canhit = true
debounce = true
wait(waittime)
canhit = false
debounce = false
end
end)
tool.Handle.Touched:Connect(function(hit)
if animation1 or animation2 then
if canhit == true then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local rootpart = humanoid.Parent.HumanoidRootPart
local BodyVelocity = Instance.new("BodyVelocity", rootpart)
--Damage
humanoid.Health = humanoid.Health - Damage
--Fling Script
BodyVelocity.Velocity = Vector3.new(math.random(0, fling), math.random(0, fling), math.random(0, fling))
rootpart.Velocity = Vector3.new(math.random(0, fling), math.random(0, fling), math.random(0, fling))
end
end
end
end)
** You are now Level 2! **