Why does this keep erroring?

function module.AfterImage(subject:Model, addTime:number)
	if not addTime then addTime = .75 end
	local clone
	clone = subject:Clone()
	local children = clone:GetChildren()
	for _,parts in pairs(children) do
		if parts:IsA("BasePart") or parts:IsA("UnionOperation") then
			if parts.Name == "Head" then
				if parts:FindFirstChildOfClass("Decal") then
					parts:FindFirstChildOfClass("Decal"):Destroy()
				end
			end
			parts.Anchored = true
			parts.Parent = workspace.VFX
			local goal = {}
			goal.Transparency = 1
			task.delay(addTime / 2, function()
				TS:Create(parts, TweenInfo.new(.6), goal):Play()
			end)
			
			parts.Color = Color3.new(0.32549, 0.196078, 0.0901961)
			parts.Transparency = .85
			parts.CanCollide = false
			if parts.Name == "Torso" or parts.Name == "Right Arm" then
				for _,child in pairs(parts:GetChildren()) do
					if child:IsA("BasePart") or child:IsA("UnionOperation") then
						child.Anchored = true
						child.Color = Color3.new(0.32549, 0.196078, 0.0901961)
						child.Transparency = .85
						child.CanCollide = false
						local goal = {}
						goal.Transparency = 1
						task.delay(addTime / 2, function()
							TS:Create(child, TweenInfo.new(.6), goal):Play()
						end)
						if child.Name == "SheatheModel" then
							if child:FindFirstChild("Katana2") then
								child:FindFirstChild("Katana2").Color = Color3.new(0.32549, 0.196078, 0.0901961)
								child:FindFirstChild("Katana2").Transparency = .85
								child:FindFirstChild("Katana2").Anchored = true
								child:FindFirstChild("Katana2").CanCollide = false
								local goal = {}
								goal.Transparency = 1
								task.delay(addTime / 2, function()
									TS:Create(child:FindFirstChild("Katana2"), TweenInfo.new(.6), goal):Play()
								end)
							end
						end
					end
				end
			end
		end
	end
end

every time i want to interact with the clone, it always says attempted to index nil, even if i want to set the parent,. i even called the functio by directly accessing the model, and it still wont work, this is supposed to work on players, but it seemed to only work on dummies

2 Likes

Are you passing through the player instead of the player’s character?

3 Likes