I've made an animation, and exported it. I'm trying to make the animation play when the player presses one, but it doesn't play. How do I fix it?

This script is located in a LocalScript in StarterPack:

player = game.Players.LocalPlayer
local fireballanimation = Instance.new("Animation", player.Character)
fireballanimation.AnimationId = "rbxassetid://319164260"
fireballanimation.Name = "Fireball Animation"

local animFireball = player.Character.Humanoid:LoadAnimation(fireballanimation)

function fireball()
	animFireball:Play()
	-- Fireball happens
end


function keybarClick()
	if s1s == "Fireball" then
		if fireballcooldown == false then
			fireballcooldown = true
		
			fireball()
		
			wait(fireballcdt)
			fireballcooldown = false
			print("Fireball ready")
		end
        end
end 

function skillCheck(inputObject, gameProcessedEvent)
	
	if inputObject.KeyCode == Enum.KeyCode.One then
		keybarClick()
	end
end 

Thanks in advance!

2 comments

1

Try adding a wait(1) at the start

0

I added 'repeat wait() until player.Character' right before returning to add the solution, thanks though!