Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Dive (serverSided)
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local serverPartsFolder = replicatedStorage.ServerParts
- local tool = script.Parent.Parent
- local effectFolder = tool.Effects
- local effects = effectFolder.Q
- local serverParts = serverPartsFolder.Water.Q
- local tweenService = game:GetService("TweenService")
- local workspaceFolder = workspace:WaitForChild("ServerEffectStorage")
- characterServer = nil
- globalDiveStart = nil
- globalDiveBall = nil
- local function turnInvisible()
- for i,v in pairs(characterServer:GetChildren()) do
- if v:IsA("BasePart") or v:IsA("MeshPart") then
- if v.Name ~= "HumanoidRootPart" then
- v.Transparency = 1
- end
- end
- end
- for i,v in pairs(characterServer:GetChildren()) do
- if v:IsA("Accessory") then
- v.Handle.Transparency = 1
- end
- end
- end
- local function turnVisible()
- for i,v in pairs(characterServer:GetChildren()) do
- if v:IsA("BasePart") or v:IsA("MeshPart") then
- if v.Name ~= "HumanoidRootPart" then
- v.Transparency = 0
- end
- end
- end
- for i,v in pairs(characterServer:GetChildren()) do
- if v:IsA("Accessory") then
- v.Handle.Transparency = 0
- end
- end
- end
- effects.RemoteEvents.Press.OnServerEvent:Connect(function(plr, localCFrame)
- plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed / 2
- print(plr.Name.." is aiming move Q.")
- end)
- effects.RemoteEvents.Release.OnServerEvent:Connect(function(plr, globalCFrame, targetCFrame)
- print(plr.Name.." is done aiming move Q. Their current CFrame is:")
- print(globalCFrame)
- for _, track in pairs (plr.character.Humanoid:GetPlayingAnimationTracks()) do
- track:Stop()
- end
- plr.Character.HumanoidRootPart.Anchored = true
- -- Sounds --
- local diveUp = effects:WaitForChild("Sounds"):WaitForChild("Dive up"):Clone()
- diveUp.Parent = workspace
- diveUp.Parent = plr.Character.HumanoidRootPart
- diveUp:Play()
- task.delay(.4, function()
- local windEffect = effects:WaitForChild("Sounds"):WaitForChild("Dive Air Sound"):Clone()
- windEffect.Parent = workspace
- windEffect.Parent = plr.Character.HumanoidRootPart
- windEffect:Play()
- end)
- task.delay(1, function()
- local splashEffect = effects:WaitForChild("Sounds"):WaitForChild("Splash"):Clone()
- splashEffect.Parent = workspace
- splashEffect.Parent = plr.Character.HumanoidRootPart
- splashEffect:Play()
- end)
- -- StartPosition --
- local diveStart = serverParts:WaitForChild("DiveStart"):Clone()
- diveStart.Parent = workspace
- diveStart.Parent = effectFolder
- diveStart.CFrame = globalCFrame
- globalDiveStart = diveStart
- -- "Player" ball effect --
- local diveBall = serverParts:WaitForChild("DiveBall"):Clone()
- diveBall.Parent = workspace
- diveBall.Parent = effectFolder
- diveBall.CFrame = plr.Character.HumanoidRootPart.CFrame
- globalDiveBall = diveBall
- --- Dive Script --
- local RunService = game:GetService("RunService")
- 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.1
- 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 -- Clamp , nill overshooting
- if t >= 1 then
- connection:Disconnect()
- -- plr.Character.HumanoidRootPart.Position = targetCFrame.Position + Vector3.new(0,10,0)
- plr.Character.HumanoidRootPart.Anchored = false
- plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed * 2
- --return
- end
- if t < 1 then
- -- Calculation/Bezier curve
- local newPosition = Bezier(t, startPos, controlPoint, endPos)
- plr.Character.HumanoidRootPart.CFrame = CFrame.new(newPosition, endPos)
- if t <.3 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(0,0,89.6)
- elseif t <.4 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(.4,0,89.6)
- elseif t <.45 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(.6,0,89.6)
- elseif t <.5 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(.8,0,89.6)
- elseif t <.55 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(.9,0,89.6)
- elseif t <.6 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(1,0,89.6)
- elseif t <.65 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(1.2,0,89.6)
- elseif t <.7 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(1.4,0,89.6)
- elseif t <.75 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(1.6,0,89.6)
- elseif t <.8 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(1.8,0,89.6)
- elseif t <.85 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(2.05,0,89.6)
- elseif t<.9 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(2.3,0,89.6)
- elseif t>.9 then
- diveBall.CFrame = CFrame.new(newPosition, endPos) * CFrame.Angles(5,0,89.6)
- end
- end
- end)
- end
- PerformDive(targetCFrame.Position + Vector3.new(0,10,0))
- characterServer = plr.Character
- turnInvisible()
- task.delay(1, function()
- local endDive = serverParts:WaitForChild("DiveEnd"):Clone()
- endDive.Parent = workspace
- endDive.Parent = effectFolder
- endDive.CFrame = targetCFrame * CFrame.new(0,5,0)
- local vortex = serverParts:WaitForChild("Vortex"):Clone()
- vortex.Parent = workspace
- vortex.Parent = effectFolder
- vortex.CFrame = endDive.CFrame
- globalDiveBall:Destroy()
- wait(1)
- for _, particle in pairs (endDive:GetDescendants()) do
- if particle:IsA("ParticleEmitter") then
- particle.Enabled = false
- end
- end
- for _, particle in pairs (vortex:GetDescendants()) do
- if particle:IsA("ParticleEmitter") then
- particle.Enabled = false
- end
- end
- wait(3)
- endDive:Destroy()
- vortex:Destroy()
- end)
- task.delay(1.5, function()
- turnVisible()
- for _, particle in pairs (globalDiveStart:GetDescendants()) do
- if particle:IsA("ParticleEmitter") then
- particle.Enabled = false
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement