I'm working on replays for a game, and whenever I clone the character, it just falls apart. Every part in the character is constantly being tweened which confuses me with why none of the parts move

https://gyazo.com/33b5dcb8491fa5daba18c0b6800c6ecb

Code:

-- The portion that records the CFrames for the replays to run off of
rec = game:GetService("RunService").RenderStepped:Connect(function()
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Character then
			if rep[v.Name] == nil then
				rep[v.Name] = {}
			end
			for c, d in pairs(v.Character:GetDescendants()) do			
				if d:IsA("BasePart") then
					rep[v.Name][d.Name] = {}
					rep[v.Name][d.Name][tick()] = d.CFrame
					if not rep[v.Name][d.Name].Object then
						rep[v.Name][d.Name].Object = d
						if not d.Archivable then
							d.Archivable = true
						end
						rep[v.Name][d.Name].Clone = d:Clone()
						rep[v.Name][d.Name].Clone.Name = rep[v.Name][d.Name].Clone.Name.."REPLAY"
						for a, b in pairs(rep[v.Name][d.Name].Clone:GetChildren()) do
							if not b:IsA("DataModelMesh") then
								b:Destroy()
							end
						end
						rep[v.Name][d.Name].Clone.CFrame = d.CFrame
					end
				end
			end
		end
	end
	rep["Puck"][tick()] = workspace.ball.ball.CFrame
	count = count + 1
	if count >= 200 then
		ed = tick()
		rec:Disconnect()
	end
end)

-- The Replay Portion
local ti = start
local cache = {}
while ti < ed do
	ti = ti + game:GetService("RunService").RenderStepped:Wait()	
	spawn(function()
		for i, v in pairs(rep) do
			if i == "Puck" then continue end
			for c, d in pairs(v) do
				if d.Clone.Parent ~= workspace then
					d.Clone.Parent = workspace
				end
				local cf = d.Clone.CFrame
				for p, q in pairs(d) do
					if typeof(q) == "CFrame" then
						cache[d.Clone] = cache[d.Clone] or {}
						if ti >= p and not cache[d.Clone][q] then
							cache[d.Clone][q] = true
							cf = q
							break
						end
					end
				end
				TS:Create(d.Clone,TweenInfo.new(1/60),{CFrame = cf})
			end
		end
	end)
end

1 comment

0

Maybe you have to collide the clone and then uncollide after a few secs so the body doesnt fall apart?