Title says it all. Also i created the animation, and renamed the Humanoid to humanoid. Everything works like the damage and cost but animation doesn't?

local player = game.Players.LocalPlayer
local char = player.Character
local phealth = char:WaitForChild("Resources"):WaitForChild("Health"):WaitForChild("Health")
local pmhealth = char:WaitForChild("Resources"):WaitForChild("Health"):WaitForChild("MaxHealth")
local pstam = char:WaitForChild("Resources"):WaitForChild("Stamina"):WaitForChild("Stamina")
local pmstam = char:WaitForChild("Resources"):WaitForChild("Stamina"):WaitForChild("MaxStamina")
local mouse = player:GetMouse()
local rs = game:GetService("ReplicatedStorage")
local CastAnimation = script.Parent.CastAnimation


local cancast = char:WaitForChild("CanCast")
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Two then
		if phealth.Value <=0 or mouse.Target == nil then return end
		local cost = script.Parent.Cost.Value
		if pstam.Value >= cost then
		if cancast.Value == true then
		print("2 was pressed")
		if mouse.Target.Parent:FindFirstChild("humanoid") then
			local enemy = mouse.Target.Parent
			if enemy.Resources.Health.Health.Value <= 0 then return end
            local distance = (char.HumanoidRootPart.Position - enemy:FindFirstChild("HumanoidRootPart").Position).magnitude
			if distance <= script.Parent.Distance.Value then
			cancast.Value = false
			local casting = char:WaitForChild("humanoid"):LoadAnimation(CastAnimation)
			local buff = char:WaitForChild("BuffFolder")
			local offensebuff = buff:WaitForChild("OffenseBuffs")
			local defensebuff = buff:WaitForChild("DefenseBuffs")
			local selfbuff = buff:WaitForChild("SelfBuffs")
			--//cost\\--
			---//BUFFS\\--
			if selfbuff:FindFirstChild("Stamina Reduction")then
				local change = cost
				cost = change - (math.floor(cost * selfbuff:FindFirstChild("Stamina Reduction").Value))
			end
			if selfbuff:FindFirstChild("Stamina Discount")then
			local change = cost
				cost = change - (math.floor(cost * selfbuff:FindFirstChild("Stamina Discount").Value))
			end
			pstam.Value = pstam.Value - cost
			casting:Play()
			--//Damaging\\--
			local damage = math.random(script.Parent.Damage.Value,math.floor(script.Parent.Damage.Value + (pmstam.Value * .02)))
			print(damage)
			if offensebuff:FindFirstChild("Major Brutality")then
				local buff = offensebuff:FindFirstChild("Major Brutality").Value
				local change = damage
				damage = math.floor(change * buff)
			end
			wait(.1)
			game.ReplicatedStorage.AbilityEvents.ShieldBashEvent:FireServer(enemy, damage)		
			wait(.5)
			cancast.Value = true
			end
			   end
			end
		end
	end
end)

2 comments

0

try :FindFirstChild("Humanoid")

0

didn't work, it's weird how all my other animations work but this doesn't