Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i fix the index nil load animation error?

local rp = game:GetService("ReplicatedStorage")
local summon = rp:WaitForChild("Summon")

local tweenservice = game:service("TweenService")

summon.OnServerEvent:connect(function(player,isactive)
	local character = player.character
	local humanoid = character.Humanoid
	local Humrp = character.HumanoidRootPart

	if isactive then
		local Humrp = character.HumanoidRootPart
		local stand = script:WaitForChild("Stand"):Clone()
		stand.Parent = character
 
		local weld = Instance.new("ManualWeld")
		weld.Part0 = stand.PrimaryPart
		weld.Part1 = Humrp
		weld.C0 = weld.Part0.CFrame.ToObjectSpace(weld.Part1.CFrame)
		weld.Parent = weld.Part0

		local AnimControl stand:FindFirstChild ("Animcontrol")

		local idle = AnimControl:LoadAnimation(script.idle)
		idle:play()

		local goal = {}
		goal.c0=weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
		goal.c1 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame * CFrame.new(-3,1,2))
		local info = TweenInfo.new(.5)
		local tween = tweenservice:create(weld,info,goal)
		tween:play()

	else


	end
end)

ERROR: ServerScriptService.Summon:24: attempt to index nil with 'LoadAnimation' Line:24

1 comment

0

LoadAnimation only works with the Humanoid and it's Animator.

1 answer

the reason it is erroring is because animcontrol is nil, most likely because it does not exist in the "stand" clone

also i would suggest not using findfirstchild because it is 8x slower than waitforchild

This discussion is preserved as it was. New answers, comments, and votes are closed.