KrYn0MoRe

sao death effect v2

Nov 27th, 2020 (edited)
1,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.66 KB | None | 0 0
  1. local partfolder = Instance.new("Folder")
  2. partfolder.Parent = script
  3.  
  4. function bind(char)
  5.     if char then else return end
  6.     local torso = char:FindFirstChild("Torso") or char:FindFirstChild("HumanoidRootPart")
  7.     local hum = char:FindFirstChildOfClass("Humanoid")
  8.  
  9.     if torso and hum then else return end
  10.    
  11.     local function break_part(part)
  12.         part.Locked = true
  13.         game:GetService("TweenService"):Create(part,TweenInfo.new(1),{Transparency = 1, Color = Color3.fromRGB(0, 170, 255)}):Play()
  14.         game:GetService("Debris"):AddItem(part,1)
  15.         for i = 1,14 do
  16.             local shard = Instance.new("WedgePart")
  17.             shard.Anchored = false
  18.             shard.CanCollide = false
  19.             shard.Locked = true
  20.             shard.Color = Color3.fromRGB(0, 170, 255)
  21.             shard.Size = Vector3.new(0.05, 0.7, 0.7)
  22.             shard.BrickColor = BrickColor.new("Cyan")
  23.             shard.Material = Enum.Material.Neon
  24.             shard.Parent = partfolder
  25.             game:GetService("TweenService"):Create(shard,TweenInfo.new(math.random(3,5)),{Transparency = 1}):Play()
  26.             game:GetService("Debris"):AddItem(shard,5)
  27.             if i == 1 then
  28.                 shard.CFrame = part.CFrame * CFrame.new(math.random(4,6)/14,0,0)
  29.             elseif i == 2 then
  30.                 shard.CFrame = part.CFrame * CFrame.new(-math.random(4,6)/14,0,0)
  31.             elseif i == 3 then
  32.                 shard.CFrame = part.CFrame * CFrame.new(0,math.random(4,6)/14,0)
  33.             elseif i == 4 then
  34.                 shard.CFrame = part.CFrame * CFrame.new(0,-math.random(4,6)/14,0)
  35.             elseif i == 5 then
  36.                 shard.CFrame = part.CFrame * CFrame.new(0,0,math.random(4,6)/14)
  37.             elseif i == 6 then
  38.                 shard.CFrame = part.CFrame * CFrame.new(0,0,-math.random(4,6)/14)
  39.             elseif i == 7 then
  40.                 shard.CFrame = part.CFrame * CFrame.new(math.random(4,6)/14,-math.random(4,6)/14,math.random(4,6)/14)
  41.             elseif i == 8 then
  42.                 shard.CFrame = part.CFrame * CFrame.new(-math.random(4,6)/14,-math.random(4,6)/14,math.random(4,6)/14)
  43.             elseif i == 9 then
  44.                 shard.CFrame = part.CFrame * CFrame.new(math.random(4,6)/14,-math.random(4,6)/14,-math.random(4,6)/14)
  45.             elseif i == 10 then
  46.                 shard.CFrame = part.CFrame * CFrame.new(-math.random(4,6)/14,-math.random(4,6)/14,-math.random(4,6)/14)
  47.             elseif i == 11 then
  48.                 shard.CFrame = part.CFrame * CFrame.new(math.random(4,6)/14,math.random(4,6)/14,math.random(4,6)/14)
  49.             elseif i == 12 then
  50.                 shard.CFrame = part.CFrame * CFrame.new(-math.random(4,6)/14,math.random(4,6)/14,math.random(4,6)/14)
  51.             elseif i == 13 then
  52.                 shard.CFrame = part.CFrame * CFrame.new(math.random(4,6)/14,math.random(4,6)/14,-math.random(4,6)/14)
  53.             elseif i == 14 then
  54.                 shard.CFrame = part.CFrame * CFrame.new(-math.random(4,6)/14,math.random(4,6)/14,-math.random(4,6)/14)
  55.             end
  56.             local body = Instance.new("BodyVelocity",shard)
  57.             body.Velocity = (shard.Position-part.Position).Unit * Vector3.new(.5,.5,.5) * math.random(7,10)
  58.             body.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  59.             local angle = Instance.new("BodyAngularVelocity",shard)
  60.             angle.AngularVelocity = Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5))
  61.             angle.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
  62.         end
  63.     end
  64.  
  65.     local function ps1(p)
  66.         local particle = Instance.new("ParticleEmitter")
  67.         particle.Parent = p
  68.         particle.Rotation = NumberRange.new(0, 360)
  69.         particle.Color = ColorSequence.new(Color3.new(0.227451, 0.431373, 1),Color3.new(0, 0.666667, 1))
  70.         particle.LightEmission = 2
  71.         particle.Texture = "rbxassetid://268667620"
  72.         particle.Transparency = NumberSequence.new(0,1)
  73.         particle.ZOffset = 2
  74.         particle.Size = NumberSequence.new(0.5, 0)
  75.         particle.Lifetime = NumberRange.new(4, 6)
  76.         particle.Rate = 1000
  77.         particle.RotSpeed = NumberRange.new(0, 360)
  78.         particle.SpreadAngle = Vector2.new(180, 180)
  79.         particle.VelocitySpread = 200
  80.         particle.Speed = NumberRange.new(0, 5)
  81.         particle.Enabled = false
  82.         local m = game:GetService("Players").RespawnTime*10
  83.         for i = 1,m do
  84.             particle:Emit(50/m)
  85.             wait(0.1)
  86.         end
  87.     end
  88.    
  89.     local function shatter()
  90.         for _,obj in pairs(char:GetDescendants()) do
  91.             if obj:IsA("BasePart") then
  92.                 local body = Instance.new("BodyVelocity",obj)
  93.                 body.Velocity = Vector3.new(math.random(-10,10)/10,math.random(-10,10)/10,math.random(-10,10)/10) * math.random(2,3)
  94.                 body.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  95.                 local angle = Instance.new("BodyAngularVelocity",obj)
  96.                 angle.AngularVelocity = Vector3.new(math.random(-3,3),math.random(-3,3),math.random(-3,3))
  97.                 angle.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
  98.                 obj.Anchored = false
  99.                 obj.CanCollide = false
  100.                 if obj.Parent == char then
  101.                     game:GetService("TweenService"):Create(obj,TweenInfo.new(4),{Transparency = 1}):Play()
  102.                     --break_part(obj)
  103.                     coroutine.wrap(ps1)(obj)
  104.                 end
  105.                 game:GetService("Debris"):AddItem(obj,5)
  106.             elseif obj:IsA("Texture") or obj:IsA("Decal") or obj:IsA("ParticleEmitter") then
  107.                 obj:Destroy()
  108.             end
  109.         end
  110.     end
  111.    
  112.     local function trans(v,t)
  113.         for _,obj in pairs(char:GetDescendants()) do
  114.             if obj.Name ~= 'HumanoidRootPart' and (obj:IsA("Part") or obj:IsA("UnionOperation") or obj:IsA("BasePart") or obj:IsA("MeshPart") or obj:IsA("Texture") or obj:IsA("Decal")) then
  115.                 game:GetService("TweenService"):Create(obj,TweenInfo.new(t),{Transparency = v}):Play()
  116.             end
  117.         end
  118.     end
  119.  
  120.     local function fx()
  121.         local die = Instance.new("Sound")
  122.         die.SoundId = 'rbxassetid://147729146'
  123.         die.Volume = 5
  124.         die.Parent = torso
  125.         die.TimePosition = 3.8
  126.         die:Play()
  127.         trans(1,0.6)
  128.         wait(0.6)
  129.         trans(0,0.6)
  130.         wait(0.6)
  131.         char:BreakJoints()
  132.         shatter()
  133.     end
  134.    
  135.     hum.BreakJointsOnDeath = false
  136.     hum.Died:Connect(function()
  137.         hum.BreakJointsOnDeath = false
  138.         fx()
  139.     end)
  140. end
  141.  
  142. for _,v in pairs(workspace:GetChildren()) do
  143.     bind(v)
  144. end
  145. workspace.ChildAdded:Connect(bind)
Add Comment
Please, Sign In to add comment