Advertisement
Firebirdzz

Example 2.2

Dec 19th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.93 KB | None | 0 0
  1. -- Prison Orb (serverSided)
  2.  
  3. local replicatedStorage = game:GetService("ReplicatedStorage")
  4. local serverPartsFolder = replicatedStorage.ServerParts
  5. local tool = script.Parent.Parent
  6. local effectFolder = tool.Effects
  7. local effects = effectFolder.Z
  8. local serverParts = serverPartsFolder.Water.Z
  9. local tweenService = game:GetService("TweenService")
  10. local workspaceFolder = workspace:WaitForChild("ServerEffectStorage")
  11. local runService = game:GetService("RunService")
  12.  
  13. local bubblePrison = serverParts:WaitForChild("Bubble Prison")
  14.  
  15. globalDiveDuration = nil
  16.  
  17. effects.RemoteEvents.ChargeAttack.OnServerEvent:Connect(function(plr, rootCFrame)
  18.     plr.Character.Humanoid.WalkSpeed = 0
  19.    
  20.     local prisonOrb = serverParts:WaitForChild("Prison Orb"):Clone()
  21.     prisonOrb.Parent = workspaceFolder
  22.     prisonOrb.CFrame = plr.Character.RightHand.CFrame
  23.    
  24.     local weld = Instance.new("WeldConstraint")
  25.     weld.Part0 = prisonOrb
  26.     weld.Part1 = plr.Character.RightHand
  27.     weld.Parent = prisonOrb
  28.    
  29. end)
  30.  
  31.  
  32. effects.RemoteEvents.StartAttack.OnServerEvent:Connect(function(plr, attackCFrame)
  33.     plr.Character.Humanoid.WalkSpeed = 16
  34.    
  35.     local prison = bubblePrison:Clone()
  36.     prison.Parent = workspaceFolder
  37.     prison.CFrame = attackCFrame
  38.    
  39.     local inner = bubblePrison.Inner:Clone()
  40.     local outline = bubblePrison.Outline:Clone()
  41.     local newTable = {inner, outline}
  42.    
  43.     for _, parts in pairs (newTable) do
  44.         local factor = 1.2
  45.         parts.Size = parts.Size * factor
  46.         parts.Transparency = 1
  47.         parts.Parent = workspace
  48.         parts.Parent = workspaceFolder
  49.         parts.CFrame = attackCFrame
  50.        
  51.         task.delay(1, function()
  52.             tweenService:Create(parts, TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = parts.Size / factor, Transparency = 0.01}):Play()
  53.         end)
  54.     end
  55.    
  56.  
  57.     local function Bezier(t, P0, P1, P2)
  58.         local point = (1-t)^2 * P0 + 2 * (1-t) * t * P1 + t^2 * P2
  59.         return point
  60.     end
  61.  
  62.     local function PerformDive(targetCframe)
  63.         local startPos = plr.Character.HumanoidRootPart.Position
  64.         local controlPoint = (startPos + targetCframe) / 2 + Vector3.new(0, 150, 0)
  65.         local endPos = targetCframe
  66.         local duration = 1
  67.         globalDiveDuration = duration
  68.         local elapsedTime = 0
  69.         local connection
  70.        
  71.         connection = runService.Heartbeat:Connect(function(dt)
  72.             elapsedTime = elapsedTime + dt
  73.             local t = elapsedTime / duration
  74.  
  75.             if t > 1 then t = 1 end
  76.  
  77.             if t >= 1 then
  78.                 connection:Disconnect()
  79.             end
  80.  
  81.             if t < 1 then
  82.        
  83.                 local newPosition = Bezier(t, startPos, controlPoint, endPos)
  84.  
  85.                 prison.CFrame = CFrame.new(newPosition, endPos)
  86.             end
  87.         end)
  88.     end
  89.  
  90.     PerformDive(attackCFrame.Position)
  91.    
  92.     -- sounds --
  93.     local throwSound = effects.Sounds:WaitForChild("Throw"):Clone()
  94.     throwSound.Parent = plr.Character.HumanoidRootPart
  95.     throwSound:Play()
  96.    
  97.     task.delay(globalDiveDuration, function()
  98.         local landSound = effects.Sounds:WaitForChild("Blob"):Clone()
  99.         landSound.Parent = plr.Character.HumanoidRootPart
  100.         landSound:Play()
  101.         task.delay(.3, function()
  102.             local lockSound = effects.Sounds:WaitForChild("Lock"):Clone()
  103.             lockSound.Parent = plr.Character.HumanoidRootPart
  104.             lockSound:Play()
  105.         end)
  106.     end)
  107.    
  108.    
  109.     -- Fix the z/x orientation by copying the orientation of the baseplate. --
  110.     task.delay(1, function()
  111.         prison.Orientation = workspace.Baseplate.Orientation
  112.     end)
  113.        
  114.     -- Tweens the prison to a bigger size. --
  115.     local tweenInfo = TweenInfo.new(.6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
  116.     local goal = {Size = Vector3.new(100, 100, 100), Transparency = 1}
  117.     local tween = tweenService:Create(prison, tweenInfo, goal)
  118.     tween:Play()
  119.    
  120.     -- "Tweens" the particles along with the size. --
  121.     for _, particles in pairs (prison:GetDescendants()) do
  122.         wait()
  123.         if particles:IsA("ParticleEmitter") then
  124.            
  125.             local startSize = 1
  126.             local targetSize = 120
  127.             local tweenTime = 1
  128.             local elapsedTime = 0
  129.            
  130.             local connection
  131.             connection = runService.Heartbeat:Connect(function(deltaTime)
  132.                 elapsedTime = elapsedTime + deltaTime
  133.                 local alpha = math.clamp(elapsedTime / tweenTime, 0, 1)
  134.                 local currentSize = startSize + (targetSize - startSize) * alpha
  135.  
  136.                 particles.Size = NumberSequence.new{NumberSequenceKeypoint.new(0, currentSize), NumberSequenceKeypoint.new(1, currentSize)}
  137.                
  138.                 if alpha >= 1 then
  139.                     connection:Disconnect()
  140.                 end
  141.             end)
  142.         end
  143.     end
  144.    
  145.     -- now after 1.2 seconds, the prison will explode like a bubble. --
  146.     task.delay(.95, function()
  147.         local factor = 1.2
  148.         for _, parts in pairs (newTable) do    
  149.             tweenService:Create(parts, TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = parts.Size * factor , Transparency = 1}):Play()
  150.         end
  151.         for _, particles in pairs (prison:GetDescendants()) do
  152.             wait()
  153.             if particles:IsA("ParticleEmitter") then
  154.  
  155.                 local startSize = 110 -- 120
  156.                 local targetSize = 150 -- 1
  157.                 local startTransparency = 0
  158.                 local targetTransparency = 1
  159.                 local tweenTime = .2 -- 1
  160.                 local elapsedTime = 0
  161.  
  162.                 local connection
  163.                 connection = runService.Heartbeat:Connect(function(deltaTime)
  164.                     elapsedTime = elapsedTime + deltaTime
  165.                     local alpha = math.clamp(elapsedTime / tweenTime, 0, 1)
  166.                     local currentSize = startSize + (targetSize - startSize) * alpha
  167.                     local currentTransparency = startTransparency + (targetTransparency - startTransparency) * alpha
  168.                    
  169.                     particles.Size = NumberSequence.new{NumberSequenceKeypoint.new(0, currentSize), NumberSequenceKeypoint.new(1, currentSize)}
  170.                     particles.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, currentTransparency), NumberSequenceKeypoint.new(1, currentTransparency)}
  171.                    
  172.                     if alpha >= 1 then
  173.                         connection:Disconnect()
  174.                     end
  175.                 end)
  176.             end
  177.         end
  178.     end)
  179.    
  180.         --
  181.    
  182.         task.delay(.6, function()
  183.         local padlock = serverParts:WaitForChild("Padlock"):Clone()
  184.         padlock.Parent = workspace:WaitForChild("ServerEffectStorage") -- workspace:WaitForChild("Watchers")
  185.         padlock:MoveTo(prison.Position)
  186.         local lookAt = Vector3.new(plr.Character.PrimaryPart.Position.X, padlock.PrimaryPart.Position.Y, plr.Character.PrimaryPart.Position.Z)
  187.         padlock:SetPrimaryPartCFrame(CFrame.new(padlock.PrimaryPart.Position, lookAt))
  188.        
  189.         local weld = Instance.new("WeldConstraint")
  190.         weld.Part0 = padlock.PrimaryPart
  191.         weld.Part1 = inner
  192.         weld.Parent = padlock.PrimaryPart
  193.  
  194.         if padlock and padlock:FindFirstChild("Humanoid") then
  195.             local animationID = 136882002510385
  196.             local newAnim = Instance.new("Animation")
  197.             newAnim.AnimationId = "rbxassetid://" .. animationID
  198.             local loadedAnim = padlock.Humanoid:LoadAnimation(newAnim)
  199.  
  200.             wait()
  201.             loadedAnim:Play()
  202.         else
  203.             warn("Padlock model or Humanoid not found.")
  204.         end
  205.        
  206.         task.delay(1, function()
  207.             for _, parts in pairs(padlock:GetChildren()) do
  208.                 if parts:IsA("MeshPart") or parts:IsA("BasePart") then
  209.                     tweenService:Create(parts, TweenInfo.new(.6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1}):Play()
  210.                 end
  211.             end
  212.         end)
  213.        
  214.     end)
  215. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement