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

My Animation can't load?

I have the code finished and the sword sounds work but the animation won't load: Animation failed to load : Workspace.Player1.ClassicSword.OverheadAnim I can't figure out what is wrong. Any help is great

SwordScript

sp.Activated:connect(function()
	local clickdelta = tick() - lastclick -- time difference between the first time you clicked and now
	if clickdelta > swingtime then -- Makes sure the player doesn't swing before the Swing time has passed
		lastclick = tick()
		hithumanoids = {} --Empty list of players that were hit in one swing, Each person hit will be added to the list. this is to make sure a single swing doesn't count at 2+ hits
		if clickdelta < swingtime + combowindow then -- if the time is less then the swing time + the Combow time then it will advance to the next combow
			combo = (combo + 1) % 3 -- Increses the combo by one and when the combo becomes 3, Sets it to 0
		else
			combo = 0
		end
		if player then
			if combo == 0 then
				event:FireClient(player, "RunAnimation", "OverheadAnim")
				SlashSound:Play()
			elseif combo == 1 then
				event:FireClient(player, "RunAnimation", "OverheadAnim")
				LungeSound:Play()
			elseif combo == 2 then
				event:FireClient(player, "RunAnimation", "OverheadAnim")
				UnsheathSound:Play()
			end
		end
	end
end)

LocalSwordScript


event.OnClientEvent:connect(function(...)
	local tuple = {...}
	if tuple[1] == "RunAnimation" then
		local anim = sp:FindFirstChild(tuple[2])
		if anim and humanoid then
			local loadedanim = humanoid:LoadAnimation(anim)
			if loadedanim then
				loadedanim:Play()
			end
		end
	end
end)

7 comments

0

Did you export the animation?

0

The Animation is apart of the "ClassicSword" in the Workplace if thats what you mean. Its its own Object.

0

By exported I mean that you uploaded it to roblox (i.e. the AssetID of the Animation object is a Roblox URL)

0

I have not

0

I belive that you have to export it in order for the LoadAnimation function to work

0

ok well now it says this Object must be in Workspace before loading animation.

0

WE GOOD

2 answers

Make sure you export the animation to ROBLOX and perhaps add a wait() at the start of the script

Avectus good point he really forgot to add the wait() there, you see wait() can be very useful sometimes. On the wiki it describes what it does, and you should know since it's very easy. Preloading animations is useful.

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