Can't locate script inside of server storage while using a server script

I’m trying to clone this animate script from server storage and parent it onto the character

image

Everything works when I fire the remote once but 2nd time it fires it doesn’t work

rEvent.OnServerEvent:Connect(function(player, instance, pos)
	print("Remote Fired")
	local Char = player.Character or player.CharacterAdded:Wait()

	if Char then 
		print("got char")
		local AnimateScript = serverStorage:FindFirstChild("Animate") -- First Remote fire I get it, 2nd remote fire this comes up as nil
		
		print(AnimateScript)
		
		if AnimateScript then 
			print("got animate script")
			Char.Archivable = true
			local CharClone = Char:Clone()
			CharClone.Parent = game.Workspace
			
			print("Cloned")
			
			for _,v in pairs(CharClone:GetDescendants()) do 
				if v:IsA("BasePart") then 
					previousCollisionGroup[v] = v.CollisionGroupId
					PhysicsService:SetPartCollisionGroup(v, "Humanoids")
				end
			end
		
			local animateClone = AnimateScript:Clone()
			AnimateScript.Parent = CharClone
			
			local CharCloneHMR = CharClone:FindFirstChild("HumanoidRootPart")
			if CharCloneHMR then 
				CharClone.PrimaryPart = CharCloneHMR
				CharClone:SetPrimaryPartCFrame(CFrame.new(pos))
			end
			
			local HMR = Char:WaitForChild("HumanoidRootPart")
			local NPCHMR = CharCloneHMR
			
			NPCHMR:SetNetworkOwner(nil)
			
			while wait (0.1) do 
				main(HMR, NPCHMR)
			end 
			
		end	
	end
end)

It works the first time the remote fires but doesn’t work on the 2nd, should I put it into replicatedstorage instead?

You are parenting the script to the character, not the clone of the script…

--#Bad Version
local animateClone = AnimateScript:Clone()
AnimateScript.Parent = CharClone

--#Fixed Version
local animateClone = AnimateScript:Clone()
animateClone.Parent = CharClone
1 Like