Animation wont load?

Barrage animation wont load Bug: Players.e4r54yt64rtq26.PlayerGui.Standless:16: attempt to index nil with ‘FindFirstChild’

02:07:31.675 - Script ‘Players.e4r54yt64rtq26.PlayerGui.Standless’, Line 16

Code:

local P = game:GetService("Players")
local LP = P.LocalPlayer
local C = LP.Character
local U = game:GetService("UserInputService")
local Enabled = false
local Enabled2 = false
local punched = false
local grabanimation = Instance.new("Animation")
grabanimation.AnimationId = "rbxassetid://5499604466"
local barrageanimation = Instance.new("Animation")
barrageanimation.AnimationId = "rbxassetid://5482283696"
local heavypunchanimation = Instance.new("Animation")
heavypunchanimation.AnimationId = "rbxassetid://5482320085"
local uppercutanimation = Instance.new("Animation")
uppercutanimation.AnimationId = "rbxassetid://5487745515"
local BA1 = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid"):LoadAnimation(barrageanimation)
local HP1 = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid"):LoadAnimation(heavypunchanimation)
local UA1 = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid"):LoadAnimation(uppercutanimation)

U.InputBegan:Connect(function(input,gameProccessed)
	if gameProccessed == false then
		if punched == false then
			if input.KeyCode == Enum.KeyCode.R then
				HP1:Play()
				game.ReplicatedStorage.HeavyPunch:FireServer()
			end
			if input.KeyCode == Enum.KeyCode.F then
				UA1:Play()
				game.ReplicatedStorage.Uppercut:FireServer()
			end
			if input.KeyCode == Enum.KeyCode.E then
				BA1:Play()
				game.ReplicatedStorage.Barrage:FireServer()
			end
		if input.KeyCode == Enum.KeyCode.T then
			Enabled2 = not Enabled2
			if Enabled2 == true then
				local BodyGyro = Instance.new("BodyGyro",C.HumanoidRootPart)
			while Enabled2 == true do
				wait(0.1)
					BodyGyro.MaxTorque = Vector3.new(0,math.huge,0)
					BodyGyro.D = 1
			BodyGyro.P = 99999
			BodyGyro.CFrame = C.HumanoidRootPart.CFrame
				BodyGyro.CFrame = BodyGyro.CFrame * CFrame.Angles(0,math.rad(30),0)
				end
			end
			if Enabled2 == false then
				C.HumanoidRootPart.BodyGyro:Destroy()
			end
		end
	if input.KeyCode == Enum.KeyCode.Comma then
		if Enabled == true then
			Enabled = false
			game.ReplicatedStorage.Respawn:FireServer(C.HumanoidRootPart.CFrame)
		end
		if Enabled == false then
				Enabled = true
				game.ReplicatedStorage.Ragdoll:FireServer()
			end
			end
		end
		end
	end)

game:GetService("UserInputService").InputEnded:Connect(function(input,gameProccessed)
	if gameProccessed == false then
		if input.KeyCode == Enum.KeyCode.E then
			BA1:Stop()
		end
	end
end)

Pretty sure, the error doesn’t correlate with this script, The error is talking about a gui, this script is talking about animations

This may have been done before the character was loaded.

Change this

local BA1 = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid"):LoadAnimation(barrageanimation)

to

game.Players.LocalPlayer.CharacterLoaded:Wait()
local BA1 = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(barrageanimation)

(Don’t forget change Character:FindFirstChild to Character:WaitForChild)

1 Like

There is no such event as CharacterLoaded, perhaps you meant CharacterAdded?

oops, i was wrong

(30 CHARACTERS)

The script is in the gui, it specifically talks about line 16 with the animation error.

The script still errors the same thing, plus :FindFirstChild yields until the specific item is found, And this is a local script which already waits for the character to be inserted automatically.

No, its not.
Returns nil if not found.

Even so, :WaitForChild can infinite yield causing the game to lag insanely when looking through the output. Still errors too:
Players.e4r54yt64rtq26.PlayerGui.Standless:16: attempt to index nil with ‘WaitForChild’

09:14:00.867 - Stack Begin

09:14:00.867 - Script ‘Players.e4r54yt64rtq26.PlayerGui.Standless’, Line 16

09:14:00.869 - Stack End

game.Players.LocalPlayer.CharacterAdded:Wait()

Did you insert it?

Solution. (30 characters 30 characters)