Okay so I had a cool idea for a Flash game, and I wanted to clone my character and have the limbs and joints take on the position and orientation of the character at the time it was spawned, I managed to get it to do that somewhat:
but my problem is the Limbs and Joints don’t take on the Position or Orientation of the Character at the time it was spawned…
here’s the code
local Effect = {}
local TweenService = game:GetService("TweenService")
local Effect = {}
local TweenService = game:GetService("TweenService")
Effect.new = function(Character)
Effect.Character = Character
Effect.Debris = Instance.new("Folder")
Effect.Debris.Name = "Debris"
Effect.Debris.Parent = Effect.Character
Effect.Clone = nil
Effect.IsSet = false
return Effect
end
function Effect:CreateClone()
self.Character.Archivable = true
self.Clone = self.Character:Clone()
for i,v in pairs(self.Clone:GetChildren()) do
if v:IsA("Script") or v:IsA("LocalScript") then
v:Destroy()
end
end
local Limbs = self:FetchLimbs()
self:SetLimbs(Limbs)
self.Clone.Parent = self.Debris
wait(2)
self.Clone:Destroy()
end
function Effect:FetchLimbs()
local Limbs = {}
for i,v in pairs(self.Character:GetChildren()) do
if v:IsA("MeshPart") then
Limbs[v.Name] = v.Orientation
print(v.Name)
end
end
return Limbs
end
function Effect:SetLimbs(Limbs)
for i,v in pairs(self.Clone:GetChildren()) do
if v:IsA("MeshPart") then
v.Orientation = Limbs[v.Name]
end
end
end
function Effect:Update()
self:CreateClone()
end
return Effect
local Motor6Ds = {
LeftUpperLeg = "LeftHip",
LeftLowerLeg = "LeftKnee",
RightLowerLeg = "RightKnee",
RightUpperArm = "RightShoulder",
RightHand = "RightWrist",
RightLowerArm = "RightElbow",
RightUpperLeg = "RightHip",
UpperTorso = "Waist",
LeftHand = "LeftWrist",
LowerTorso = "Root",
RightFoot = "RightAnkle",
Head = "Neck",
LeftUpperArm = "LeftShoulder",
LeftFoot = "LeftAnkle",
LeftLowerArm = "LeftElbow"
}
local Effect = {}
Effect.__index = Effect
local TweenService = game:GetService("TweenService")
function Effect.new(Character)
local self = setmetatable({}, Effect)
self.Character = Character
self.Debris = Instance.new("Folder")
self.Debris.Name = "Debris"
self.Debris.Parent = self.Character
self.Clone = nil
self.IsSet = false
return self
end
function Effect:CreateClone()
self.Character.Archivable = true
self.Clone = self.Character:Clone()
for i,v in pairs(self.Clone:GetChildren()) do
if v:IsA("Script") or v:IsA("LocalScript") then
v:Destroy()
end
end
local Limbs = self:FetchLimbs()
self:SetLimbs(Limbs)
self.Clone.Parent = self.Debris
wait(2)
self.Clone:Destroy()
end
function Effect:FetchLimbs()
local Limbs = {}
for i,v in pairs(self.Character:GetChildren()) do
if v:IsA("MeshPart") then
Limbs[v.Name] = v[Motor6Ds[v.Name]].Transform
print(v.Name)
end
end
return Limbs
end
function Effect:SetLimbs(Limbs)
for i,v in pairs(self.Clone:GetChildren()) do
if v:IsA("MeshPart") then
v[Motor6Ds[v.Name]].Transform = Limbs[v.Name]
end
end
end
function Effect:Update()
self:CreateClone()
end
return Effect