Here’s how I do this
first to get the disemble effect run a loop through the model then clone those part, apply collision and set the original part’s transparency to 1 you can make this trigger whenever the shield value go 0 I guess
for i,v in pairs(npc:GetChildren()) do -- run a loop to get all the parts
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then -- clones the parts that isn't HumanoidRootPart
v.Transparency = 1
local new = v:Clone()
for i,v in pairs(new:GetDescendants()) do -- destroy other thing else except SpecialMesh for the head
if not v:IsA("SpecialMesh") then
v:Destroy()
end
end
new.Anchored = false
new.CanCollide = true
new.Parent = Folder
new.CFrame = v.CFrame
new.Transparency = 0
end
end
to assemble use tweenservice and move the part back into the place then after the tween completed, delete the fake part, and turn the orginal part’s transparency back to 0
for i,part in pairs(Folder:GetChildren()) do -- run a loop to get all the fake part
for i, originalPart in pairs(npc:GetChildren()) do -- run a loop to get all the orginal part
if originalPart.Name == part.Name then -- create a tween that put the part back to its orginal position if the name match
local t = T:Create(part, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CFrame = originalPart.CFrame})
t:Play()
task.spawn(function() -- this just do the magnetic beam thingy (Not essensual and can be delete)
local att1 = Instance.new("Attachment", part)
local att2 = Instance.new("Attachment", core)
for i,v in pairs(BeamParticle:GetChildren()) do
if v:IsA("Beam") then
local new = v:Clone()
new.Parent = part
new.Attachment0 = att1
new.Attachment1 = att2
end
end
end)
t.Completed:Connect(function() -- when the tween finish delete the fake part then set orginal part's transparency back to 0
local new = SparkEffect:Clone()
new.Parent = Folder
new.CFrame = part.CFrame
task.delay(.1, function()
for i,v in pairs(new:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = false
task.delay(.1, function()
new:Destroy()
end)
end
end
end)
part:Destroy()
originalPart.Transparency = 0
end)
task.wait(.2) -- add a little bit of delay so it look like the part is connecting back one by one
end
end
end
Entire Code
local T = game:GetService("TweenService")
local npc = script.Parent
local hum = npc.Humanoid
local Anim = script.WalkAnim
hum.Animator:LoadAnimation(Anim):Play() -- loop running animation
local SparkEffect = game:GetService("ReplicatedStorage").RandomStuff.SparkEffect
local BeamParticle = game:GetService("ReplicatedStorage").RandomStuff.BeamParticle
local core = npc["Reactor Core Orb"].Inner
local oldLocation = npc.PrimaryPart.CFrame
local Folder = Instance.new("Folder", workspace) -- make a new folder to keep all the parts
local IsSeperate = false -- toggle
while task.wait(5) do
if IsSeperate then
IsSeperate = false
npc.PrimaryPart.CFrame = oldLocation
-- for some reason whenever the part got clone the collision of the center piece such as torso will stuck inside the body of the original part
-- and push the model into a straight position which is why this line exists
for i,part in pairs(Folder:GetChildren()) do -- run a loop to get all the fake part
for i, originalPart in pairs(npc:GetChildren()) do -- run a loop to get all the orginal part
if originalPart.Name == part.Name then -- create a tween that put the part back to its orginal position if the name match
local t = T:Create(part, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CFrame = originalPart.CFrame})
t:Play()
task.spawn(function() -- this just do the magnetic beam thingy
local att1 = Instance.new("Attachment", part)
local att2 = Instance.new("Attachment", core)
for i,v in pairs(BeamParticle:GetChildren()) do
if v:IsA("Beam") then
local new = v:Clone()
new.Parent = part
new.Attachment0 = att1
new.Attachment1 = att2
end
end
end)
t.Completed:Connect(function() -- when the tween finish delete the fake part then set orginal part's transparency back to 0
local new = SparkEffect:Clone()
new.Parent = Folder
new.CFrame = part.CFrame
task.delay(.1, function()
for i,v in pairs(new:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = false
task.delay(.1, function()
new:Destroy()
end)
end
end
end)
part:Destroy()
originalPart.Transparency = 0
end)
task.wait(.2) -- add a little bit of delay so it look like the part is connecting back one by one
end
end
end
else
IsSeperate = true
for i,v in pairs(npc:GetChildren()) do -- run a loop to get all the parts
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then -- clones the parts that isn't HumanoidRootPart
v.Transparency = 1
local new = v:Clone()
for i,v in pairs(new:GetDescendants()) do -- destroy other thing else except SpecialMesh for the head
if not v:IsA("SpecialMesh") then
v:Destroy()
end
end
new.Anchored = false
new.CanCollide = true
new.Parent = Folder
new.CFrame = v.CFrame
new.Transparency = 0
end
end
end
end