When I clone a character, why does it fall apart?
Asked by
4 years ago Edited 4 years ago
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:
02 | rec = game:GetService( "RunService" ).RenderStepped:Connect( function () |
03 | for i, v in pairs (game.Players:GetPlayers()) do |
05 | if rep [ v.Name ] = = nil then |
08 | for c, d in pairs (v.Character:GetDescendants()) do |
09 | if d:IsA( "BasePart" ) then |
10 | rep [ v.Name ] [ d.Name ] = { } |
11 | rep [ v.Name ] [ d.Name ] [ tick() ] = d.CFrame |
12 | if not rep [ v.Name ] [ d.Name ] .Object then |
13 | rep [ v.Name ] [ d.Name ] .Object = d |
14 | if not d.Archivable then |
17 | rep [ v.Name ] [ d.Name ] .Clone = d:Clone() |
18 | rep [ v.Name ] [ d.Name ] .Clone.Name = rep [ v.Name ] [ d.Name ] .Clone.Name.. "REPLAY" |
19 | for a, b in pairs (rep [ v.Name ] [ d.Name ] .Clone:GetChildren()) do |
20 | if not b:IsA( "DataModelMesh" ) then |
24 | rep [ v.Name ] [ d.Name ] .Clone.CFrame = d.CFrame |
30 | rep [ "Puck" ] [ tick() ] = workspace.ball.ball.CFrame |
42 | ti = ti + game:GetService( "RunService" ).RenderStepped:Wait() |
44 | for i, v in pairs (rep) do |
45 | if i = = "Puck" then continue end |
46 | for c, d in pairs (v) do |
47 | if d.Clone.Parent ~ = workspace then |
48 | d.Clone.Parent = workspace |
50 | local cf = d.Clone.CFrame |
51 | for p, q in pairs (d) do |
52 | if typeof(q) = = "CFrame" then |
53 | cache [ d.Clone ] = cache [ d.Clone ] or { } |
54 | if ti > = p and not cache [ d.Clone ] [ q ] then |
55 | cache [ d.Clone ] [ q ] = true |
61 | TS:Create(d.Clone,TweenInfo.new( 1 / 60 ), { CFrame = cf } ) |