Animation Issue

So, The script only works if the NPC is inserted into workspace, but my game is cloning the NPC in a folder from replicatedstorage so when I move the item into there, when the item spawns into the map the animation no longer plays.


image

By any chance can you completely rephrase everything you just said, and maybe include some examples of whats happening

There’s a folder called “Set” In workspace where all the items clone to. The “Male” Folder from Replicated Storage clones into the Set folder in workspace but the animations no longer work. When I manually place the “Male” folder into the “Set” The Animations work. The script is listed above.

What you should probably do is make it so the animation isnt loaded into it is in the workspace:

local char = script.Parent
local hum = char:FindFirstChildOfClass('Humanoid')
local Animation = script:FindFirstChildOfClass('Animation')

char:GetPropertyChangedSignal('Parent'):Connect(function()
    if workspace:IsAncestorOf(char) then
         local loadedAnim = hum:FindFirstChild('Animator'):LoadAnimation(Animation)
         loadedAnim:Play
    end
end

What this does is it tells when the parent changes, and if its a descendant of the workspace (meaning its in the workspace) then we load the animation, it should work, but dont quote me

It did not help and it did not work

Hmm I see.
What I would recommend doing instead, is when you clone all the rigs and put them into the workspace, thats when you would load the animation and play it.

So if you want an example of how to do that, could you send the code to how you put the stuff in the workspace? And please dont send an image, send the actual code. You can use ctrl + e to format the code

local function RefreshSet()
	if workspace.Set:FindFirstChildOfClass('Folder') then
		if not workspace:GetAttribute('TestingMode') and workspace.Set:FindFirstChildWhichIsA('Folder').Name == gender then
			for i,item in workspace.Set:FindFirstChildOfClass('Folder'):GetChildren() do
				ClientItemHandler.createClicker(item)
			end
			warn('Failed to add highlights because folder still in workspace.')
			return
		end
		workspace.Set:FindFirstChildOfClass('Folder'):Destroy()
	end
	
	local newSet = sets[gender]:Clone()
	newSet.Parent = workspace.Set
	newSet:SetAttribute('Old', true)
	
	for i,item in newSet:GetChildren() do
		ClientItemHandler.createClicker(item)
	end

Animation Script:

local hum = script.Parent:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))
anim.Looped = true
anim:Play()

Wouldn’t (wait) fix this if that method worked? Even waiting after its cloned and the animation being played 10 seconds later it still doesn’t play

A wait would probably work actually, nice thinking

I mean it doesn’t work, so the way you’re saying it would work wouldn’t

Does anyone know a Solution… Yep

I didnt pick up on that, mb.

Try combing these two scripts so the animation players after the thing is created.

Other than that I honestly dont know, weird.

If I could I wouldn’t be here asking