Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Prison Orb (serverSided)
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local serverPartsFolder = replicatedStorage.ServerParts
- local tool = script.Parent.Parent
- local effectFolder = tool.Effects
- local effects = effectFolder.Z
- local serverParts = serverPartsFolder.Water.Z
- local tweenService = game:GetService("TweenService")
- local workspaceFolder = workspace:WaitForChild("ServerEffectStorage")
- local runService = game:GetService("RunService")
- local bubblePrison = serverParts:WaitForChild("Bubble Prison")
- globalDiveDuration = nil
- effects.RemoteEvents.ChargeAttack.OnServerEvent:Connect(function(plr, rootCFrame)
- plr.Character.Humanoid.WalkSpeed = 0
- local prisonOrb = serverParts:WaitForChild("Prison Orb"):Clone()
- prisonOrb.Parent = workspaceFolder
- prisonOrb.CFrame = plr.Character.RightHand.CFrame
- local weld = Instance.new("WeldConstraint")
- weld.Part0 = prisonOrb
- weld.Part1 = plr.Character.RightHand
- weld.Parent = prisonOrb
- end)
- effects.RemoteEvents.StartAttack.OnServerEvent:Connect(function(plr, attackCFrame)
- plr.Character.Humanoid.WalkSpeed = 16
- local prison = bubblePrison:Clone()
- prison.Parent = workspaceFolder
- prison.CFrame = attackCFrame
- local inner = bubblePrison.Inner:Clone()
- local outline = bubblePrison.Outline:Clone()
- local newTable = {inner, outline}
- for _, parts in pairs (newTable) do
- local factor = 1.2
- parts.Size = parts.Size * factor
- parts.Transparency = 1
- parts.Parent = workspace
- parts.Parent = workspaceFolder
- parts.CFrame = attackCFrame
- task.delay(1, function()
- tweenService:Create(parts, TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = parts.Size / factor, Transparency = 0.01}):Play()
- end)
- end
- local function Bezier(t, P0, P1, P2)
- local point = (1-t)^2 * P0 + 2 * (1-t) * t * P1 + t^2 * P2
- return point
- end
- local function PerformDive(targetCframe)
- local startPos = plr.Character.HumanoidRootPart.Position
- local controlPoint = (startPos + targetCframe) / 2 + Vector3.new(0, 150, 0)
- local endPos = targetCframe
- local duration = 1
- globalDiveDuration = duration
- local elapsedTime = 0
- local connection
- connection = runService.Heartbeat:Connect(function(dt)
- elapsedTime = elapsedTime + dt
- local t = elapsedTime / duration
- if t > 1 then t = 1 end
- if t >= 1 then
- connection:Disconnect()
- end
- if t < 1 then
- local newPosition = Bezier(t, startPos, controlPoint, endPos)
- prison.CFrame = CFrame.new(newPosition, endPos)
- end
- end)
- end
- PerformDive(attackCFrame.Position)
- -- sounds --
- local throwSound = effects.Sounds:WaitForChild("Throw"):Clone()
- throwSound.Parent = plr.Character.HumanoidRootPart
- throwSound:Play()
- task.delay(globalDiveDuration, function()
- local landSound = effects.Sounds:WaitForChild("Blob"):Clone()
- landSound.Parent = plr.Character.HumanoidRootPart
- landSound:Play()
- task.delay(.3, function()
- local lockSound = effects.Sounds:WaitForChild("Lock"):Clone()
- lockSound.Parent = plr.Character.HumanoidRootPart
- lockSound:Play()
- end)
- end)
- -- Fix the z/x orientation by copying the orientation of the baseplate. --
- task.delay(1, function()
- prison.Orientation = workspace.Baseplate.Orientation
- end)
- -- Tweens the prison to a bigger size. --
- local tweenInfo = TweenInfo.new(.6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
- local goal = {Size = Vector3.new(100, 100, 100), Transparency = 1}
- local tween = tweenService:Create(prison, tweenInfo, goal)
- tween:Play()
- -- "Tweens" the particles along with the size. --
- for _, particles in pairs (prison:GetDescendants()) do
- wait()
- if particles:IsA("ParticleEmitter") then
- local startSize = 1
- local targetSize = 120
- local tweenTime = 1
- local elapsedTime = 0
- local connection
- connection = runService.Heartbeat:Connect(function(deltaTime)
- elapsedTime = elapsedTime + deltaTime
- local alpha = math.clamp(elapsedTime / tweenTime, 0, 1)
- local currentSize = startSize + (targetSize - startSize) * alpha
- particles.Size = NumberSequence.new{NumberSequenceKeypoint.new(0, currentSize), NumberSequenceKeypoint.new(1, currentSize)}
- if alpha >= 1 then
- connection:Disconnect()
- end
- end)
- end
- end
- -- now after 1.2 seconds, the prison will explode like a bubble. --
- task.delay(.95, function()
- local factor = 1.2
- for _, parts in pairs (newTable) do
- tweenService:Create(parts, TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = parts.Size * factor , Transparency = 1}):Play()
- end
- for _, particles in pairs (prison:GetDescendants()) do
- wait()
- if particles:IsA("ParticleEmitter") then
- local startSize = 110 -- 120
- local targetSize = 150 -- 1
- local startTransparency = 0
- local targetTransparency = 1
- local tweenTime = .2 -- 1
- local elapsedTime = 0
- local connection
- connection = runService.Heartbeat:Connect(function(deltaTime)
- elapsedTime = elapsedTime + deltaTime
- local alpha = math.clamp(elapsedTime / tweenTime, 0, 1)
- local currentSize = startSize + (targetSize - startSize) * alpha
- local currentTransparency = startTransparency + (targetTransparency - startTransparency) * alpha
- particles.Size = NumberSequence.new{NumberSequenceKeypoint.new(0, currentSize), NumberSequenceKeypoint.new(1, currentSize)}
- particles.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, currentTransparency), NumberSequenceKeypoint.new(1, currentTransparency)}
- if alpha >= 1 then
- connection:Disconnect()
- end
- end)
- end
- end
- end)
- --
- task.delay(.6, function()
- local padlock = serverParts:WaitForChild("Padlock"):Clone()
- padlock.Parent = workspace:WaitForChild("ServerEffectStorage") -- workspace:WaitForChild("Watchers")
- padlock:MoveTo(prison.Position)
- local lookAt = Vector3.new(plr.Character.PrimaryPart.Position.X, padlock.PrimaryPart.Position.Y, plr.Character.PrimaryPart.Position.Z)
- padlock:SetPrimaryPartCFrame(CFrame.new(padlock.PrimaryPart.Position, lookAt))
- local weld = Instance.new("WeldConstraint")
- weld.Part0 = padlock.PrimaryPart
- weld.Part1 = inner
- weld.Parent = padlock.PrimaryPart
- if padlock and padlock:FindFirstChild("Humanoid") then
- local animationID = 136882002510385
- local newAnim = Instance.new("Animation")
- newAnim.AnimationId = "rbxassetid://" .. animationID
- local loadedAnim = padlock.Humanoid:LoadAnimation(newAnim)
- wait()
- loadedAnim:Play()
- else
- warn("Padlock model or Humanoid not found.")
- end
- task.delay(1, function()
- for _, parts in pairs(padlock:GetChildren()) do
- if parts:IsA("MeshPart") or parts:IsA("BasePart") then
- tweenService:Create(parts, TweenInfo.new(.6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1}):Play()
- end
- end
- end)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement