LoadAnimation requires an Animation object

How can i fix this error?

local player = script.Parent.Parent.Parent.Parent.Parent.Parent

local char = player.Character

local selectedStyle = "Majin"
local button = script.Parent
local hum = char:WaitForChild('Humanoid')

button.MouseButton1Click:Connect(function()

	local AnimationSets = game.ServerStorage.AnimationSets
	local Styles = AnimationSets:FindFirstChild('Majin')
	print('Majin')
	if AnimationSets:FindFirstChild(player.Name) then
		Styles = AnimationSets:FindFirstChild(player.Name)
	end	

	char:WaitForChild('Client'):FindFirstChild('Animations'):Destroy()

	local AnimationFolder = Styles:Clone()
	AnimationFolder.Name = 'Animations'
	AnimationFolder.Parent = char:WaitForChild('Client')
	
	local Animations = char:WaitForChild('Client'):WaitForChild('Animations')

	for _, animation in Animations:GetChildren() do
		local animator = hum:WaitForChild("Animator")
		local loadedAnim = animator:LoadAnimation(animation)<< line erroring
	end

	for _, animation2 in Animations['Fighting Style']:GetChildren() do
		local animator2 = hum:WaitForChild("Animator")
		local loadedAnim = animator2:LoadAnimation(animation2)<< line erroring
	end


	selectedStyle = button.Name
end)

LoadAnimation can be called from localscript only, in other cases like giving animation to NPC you can use script

thanks for the info and will this script still work for localscript?

Yup as long as the folders are not inside server storage or server script service

alright i just place the folder in replicated storage

Just add a remote event that server will use to communicate with client and let it play anims

It is simpler and easier so you shouldn’t do alot

oof i’ll give it try lol i’m not that good like use to be
and can you help me with one last thing?

so i made a dash script but… It is whacky and it doesn’t find all the parts or models in the player and i been trying to fix it without doing alot

for _, v in pairs(c:GetChildren()) do
				if v:IsA("Accessory") then
					if v:FindFirstChild('Handle') then
						v:FindFirstChild('Handle').Transparency = 1
					end
				end
			end
			for _, v in pairs(c:GetChildren()) do
				if v:IsA("Part") then
					v.Transparency = 1
				end
			end
			
			for _, v in pairs(c:GetChildren()) do
				if v:IsA("Model")  then
					if v:IsA("Part") or v:IsA("MeshPart") then
						v.Transparency = 1
					end
				end
			end
			for _, v in pairs(c.PlayerOutline:GetChildren()) do
				if v:IsA("MeshPart") then
					v.Transparency = 1
				end
			end	```

I am new to the forum and I don’t really know how to send script in frame like you do so sorry

oh you just put the ` next to number 1 three times and the lua right after it and after that you put your code then the three ``` again and boom code in

also i just put this in replicated storage to test it and it gives the same error still

1lua print("hello world") thanks😊

You should change this ro replicated storage

welcome and this is my first time doing this type of scripting LOL you think you can help me fix it up to work? i never done fighting styles before and having to load new animations to play them through button select it was always

and i did i change it to replicated storage

Can you send the error screenshot

https://gyazo.com/d7ff308965ed13e5b2ce94dd4d613d11

for _, animation in Animations:GetChildren() do 
		local animator = hum:WaitForChild("Animator")
		local loadedAnim = animator:LoadAnimation(animation)
	end
end)```

Waiitttttt omg sorry :sweat_smile: you must create animation object first

i have it places the new animations into the folder