Index nil with play animation

Hello, Im currently making a fighting game based on JJBA (i know its the 2983213 jjba game), but ive got a problem on a script, or an animation i guess.

What ive been trying to achieve is when this event is fired (Client to Server) an animation plays (the idle animation for the stand), but it keeps giving me an error. (the stand doesnt have humanoid, it does have AnimControl)

This is the code im using:

game.ReplicatedStorage.Release.OnServerEvent:Connect(function(plr, standname)
		local char = plr.Character
		local stand = char:WaitForChild(standname)
		local humanoidroot = char:WaitForChild("HumanoidRootPart")
		local Anim = stand:FindFirstChild("AnimationController")
		local idle = Anim:LoadAnimation(workspace.Animations.Idle)
		idle:Play()
	end)

And this is the error it gives:

 ServerScriptService.Release:6: attempt to index nil with 'LoadAnimation

Support is appreciated.
Also im not really a good scripter so any info about how to improve my scripting is very much appreciated!

Try using this

local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Release.OnServerEvent:Connect(function(Player, StandName)
local Character = Player.Character
local Stand = Character:WaitForChild(StandName)
local AnimationController = Stand:FindFirstChildOfClass("AnimationController")
local IdleAnimation = AnimationController:LoadAnimation(workspace.Animation.Idle)
IdleAnimation:Play()
end)

Client:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Release:FireServer("StandNameHere")

What I’m guessing is you did

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
ReplicatedStorage.Release:FireServer(Players.LocalPlayer, "StandNameHere")

which wouldn’t work because the player is already defined when you fire a remote and so it would consider your player as the inputted standname

It still keeps giving me the same error, Thanks for your answer tho.
also

I actually did this,

local summon = game.ReplicatedStorage:WaitForChild("Release")

summon:FireServer("KingCrimson")

(Thats the script i had on the start since i know the player is already defined.)

Are you sure theres nothing wrong with the animationcontroller?

Just a hunch, but try switching stand:FindFirstChild("AnimationController") to WaitForChild like I did below, it’s possible its not getting it. If in output it says Infinite Wait or something along those lines then you know that what your trying to get isnt actually there. Same goes for the Idle animation which I also added a WaitForChild. If none of these display anything in output then something is wrong with the remote.

game.ReplicatedStorage.Release.OnServerEvent:Connect(function(plr, standname)
	local char = plr.Character
	local stand = char:WaitForChild(standname)
	local humanoidroot = char:WaitForChild("HumanoidRootPart")
	local Anim = stand:WaitForChild("AnimationController") 
	local idle = Anim:LoadAnimation(workspace:WaitForChild("Animations"):WaitForChild("Idle"))
	idle:Play()
end)

Im not really sure, but i tried Odawg’s solution and it doesnt work, keeps giving me the same error.

Ive already tried this and it gives me the error you say.
Maybe its because the stand is cloned maybe?

my bad I put char:WaitForChild instead of stand:WaitForChild

Yeah i noticed that, and changed it.

and it still errors? thats really weird. If that’s the case then the stand might be the issue.

try this after where you get the stand variable:

if not stand then warn("Stand does not exist!") return end

Oh I think you created the stand on the client side! If that’s the case then you need to create it on the serverside instead or handle animations on the client. The server cannot see what is being made on the client without the use of remote events.

1 Like

OHH I completely forgot! Thanks!!!

1 Like