Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Controllable Wave Hunter Script (Client control)
- local tool = script.Parent.Parent
- local userInputService = game:GetService("UserInputService")
- local runService = game:GetService("RunService")
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local effects = tool.Effects.E
- local remoteEvents = effects.RemoteEvents
- local tool = script.Parent.Parent
- local tweenService = game:GetService("TweenService")
- local serverPartsFolder = replicatedStorage.ServerParts
- local serverParts = serverPartsFolder.Water.E
- local tweenService = game:GetService("TweenService")
- local workspaceFolder = workspace:WaitForChild("ServerEffectStorage")
- local player = game.Players.LocalPlayer
- local character = player.Character
- local hmrp = character.HumanoidRootPart
- local mouse = player:GetMouse()
- local camera = workspace.CurrentCamera
- cooldown = 10
- equipped = false
- isPressing = false
- minimumHoldTime = 6
- maximumHoldTime = 13
- cutceneTime = 3
- canBeRealeased = false
- globalVelocity = nil
- globalTurnConnection = nil
- globalMoveConnection = nil
- currentSideVelocity = nil
- maxSideVelocity = nil
- sideAcceleration = nil
- dampingFactor = nil
- tempTrue = true
- casted = false
- -- // SCREENSHAKE SCRIPT \\
- local shakeDuration = 0
- local shakeMagnitude = 0
- local shakeTime = 0
- local Camera = workspace.CurrentCamera
- local function Trigger(duration, magnitude)
- shakeDuration = duration
- shakeMagnitude = magnitude
- shakeTime = 0
- end
- local function LoadUpdate(dt)
- if shakeDuration > 0 then
- shakeTime = shakeTime + dt
- if shakeTime >= shakeDuration then
- shakeDuration = 0
- shakeMagnitude = 0
- Camera.CFrame = Camera.CFrame + Camera.CFrame.LookVector
- else
- local dx = math.random(-shakeMagnitude, shakeMagnitude) * .1
- local dy = math.random(-shakeMagnitude, shakeMagnitude) * .1
- local dz = math.random(-shakeMagnitude, shakeMagnitude) * .1
- Camera.CFrame = Camera.CFrame * CFrame.new(dx,dy,dz)
- end
- end
- end
- game:GetService("RunService").RenderStepped:Connect(LoadUpdate)
- --
- local function createCameraPart(player, side)
- local character = player.Character or player.CharacterAdded:Wait()
- local rootPart = character:WaitForChild("HumanoidRootPart")
- local cameraPart = Instance.new("Part")
- cameraPart.Name = "CameraPart"
- cameraPart.Anchored = true
- cameraPart.CanCollide = false
- cameraPart.Transparency = 1
- cameraPart.Size = Vector3.new(1, 1, 1)
- cameraPart.Parent = workspace
- local sideOffset = side == "right" and 1 or -1
- local distance = 200
- local height = 120
- local sideVector = rootPart.CFrame.RightVector * distance * sideOffset
- local upwardVector = Vector3.new(0, height, 0)
- local cameraPosition = rootPart.Position + sideVector + upwardVector
- cameraPart.CFrame = CFrame.new(cameraPosition, rootPart.Position)
- local camera = workspace.CurrentCamera
- camera.CameraType = Enum.CameraType.Scriptable
- camera.CFrame = cameraPart.CFrame
- return cameraPart
- end
- tool.Equipped:Connect(function()
- equipped = true
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- if globalMoveConnection then
- globalMoveConnection:Disconnect()
- globalTurnConnection:Disconnect()
- end
- if globalVelocity then
- globalVelocity:Destroy()
- end
- end)
- userInputService.InputBegan:Connect(function(input, gameprocess)
- if gameprocess then return end
- if input.KeyCode == Enum.KeyCode.E and equipped == true and casted == false then
- task.spawn(function()
- for i = 1, minimumHoldTime do
- wait(1)
- end
- canBeRealeased = true
- end)
- task.spawn(function()
- for i = 1, maximumHoldTime do
- wait(1)
- end
- if casted == false then
- casted = true
- local localCFrame = character.HumanoidRootPart.CFrame
- remoteEvents.Dive:FireServer(localCFrame)
- local player = game.Players.LocalPlayer
- local cameraPart = createCameraPart(player, "Right")
- task.delay(cutceneTime, function()
- local camera = workspace.CurrentCamera
- camera.CameraType = Enum.CameraType.Custom
- if cameraPart then
- cameraPart:Destroy()
- end
- end)
- wait(10)
- casted = false
- end
- end)
- print(player.Name.." has pressed E. It's being held down. Using attack: Wave Hunter.")
- isPressing = true
- local localCFrame = character.HumanoidRootPart.CFrame
- remoteEvents:WaitForChild("Hold"):FireServer(localCFrame)
- task.delay(13.5, function()
- local Flasher = effects.Lighting.Flash:Clone()
- Flasher.Brightness = 1
- local function WhiteColor()
- Flasher.TintColor = Color3.new(255,255,255)
- end
- local function BlackColor()
- Flasher.TintColor = Color3.new(0,0,0)
- end
- Flasher.Parent = game.Lighting
- for i = 1,2 do wait(.02)
- WhiteColor()
- wait(.02)
- BlackColor()
- end
- game.Debris:AddItem(Flasher,0)
- Trigger(1, 30)
- wait(3)
- Trigger(3, 15)
- wait(1.5)
- Trigger(5,6)
- end)
- Trigger(1, 35)
- task.delay(1, function()
- Trigger(7, 20)
- task.delay(7, function()
- Trigger(5.5, 25)
- end)
- end)
- -- Tweening the camera out, then view the player from above.
- local tweenInfo = TweenInfo.new(.55, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
- local tweenFov = tweenService:Create(camera, tweenInfo, { FieldOfView = 250 })
- tweenFov:Play()
- local updatingCamera = false
- local originalMinZoom = player.CameraMinZoomDistance
- local originalMaxZoom = player.CameraMaxZoomDistance
- local function forceZoomOut(targetZoom)
- player.CameraMinZoomDistance = targetZoom
- player.CameraMaxZoomDistance = targetZoom
- end
- local function restoreZoom()
- player.CameraMinZoomDistance = originalMinZoom
- player.CameraMaxZoomDistance = originalMaxZoom
- end
- forceZoomOut(100)
- task.delay(5, restoreZoom)
- local currentCFrame = camera.CFrame
- local height = 50
- local rotation = CFrame.Angles(math.rad(-60), 0, 0)
- local newCFrame = CFrame.new(currentCFrame.Position.X, player.Character.HumanoidRootPart.Position.Y + height, currentCFrame.Position.Z) * rotation
- camera.CFrame = newCFrame
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local hrp = character:WaitForChild("HumanoidRootPart")
- local targetHeight = hrp.Position.Y + 15
- local TweenService = game:GetService("TweenService")
- local goal = {CFrame = hrp.CFrame + Vector3.new(0, targetHeight - hrp.Position.Y, 0)}
- local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
- local liftTween = TweenService:Create(hrp, tweenInfo, goal)
- liftTween:Play()
- liftTween.Completed:Connect(function()
- -- Debug, the start disconnect: immediately letting the player face the mouse's direction: --
- local root = hmrp
- local rootPos, mousePos = root.Position, mouse.Hit.Position
- root.CFrame = CFrame.new(rootPos, Vector3.new(mousePos.X, rootPos.Y, mousePos.Z))
- --
- local velocity = Instance.new("BodyVelocity")
- velocity.Parent = player.Character.HumanoidRootPart
- velocity.MaxForce = Vector3.new(10000,math.huge,10000)
- velocity.Velocity = Vector3.new(0,100,0)
- globalVelocity = velocity
- -- Summary:
- -- [1] left, right
- -- [2] up, down
- -- [3] back, forward
- local rootPart = character:WaitForChild("HumanoidRootPart")
- local speedUpCounter = 1
- local function updateVelocityTowardsMouse()
- if equipped == true then
- local mousePos = Vector3.new(mouse.Hit.p.X, rootPart.Position.Y, mouse.Hit.p.Z)
- local playerPos = rootPart.Position
- local direction = (mousePos - playerPos).Unit
- local forwardDirection = rootPart.CFrame.LookVector
- local dotProduct = forwardDirection:Dot(direction)
- if dotProduct > 0.5 then
- local sideFactor = math.clamp(dotProduct, 0.3, 1)
- direction = Vector3.new(direction.X * sideFactor, 0, direction.Z * sideFactor)
- velocity.Velocity = direction * (38 * speedUpCounter)
- speedUpCounter += 0.015
- else
- if not player.PlayerGui:FindFirstChild("Too sharp turn") then
- print("User has took a too sharp turn, cancelled attack.")
- velocity:Destroy()
- globalMoveConnection:Disconnect()
- globalTurnConnection:Disconnect()
- local gui = effects:WaitForChild("GUIs"):WaitForChild("Too sharp turn"):Clone()
- gui.Parent = player.PlayerGui
- local background = gui:WaitForChild("Background")
- local startPosition = UDim2.new(1.1, 0, 0.8, 0)
- local targetPosition = UDim2.new(0.8, 0, 0.8, 0)
- local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
- local moveToTarget = tweenService:Create(background, tweenInfo, {Position = targetPosition})
- local moveToStart = tweenService:Create(background, tweenInfo, {Position = startPosition})
- moveToTarget:Play()
- moveToTarget.Completed:Connect(function()
- wait(5)
- moveToStart:Play()
- task.delay(1, function()
- gui:Destroy()
- end)
- end)
- end
- end
- end
- end
- local function faceMouse()
- local turnSpeed = 0.04
- local runService = game:GetService("RunService")
- local mousePos = Vector3.new(mouse.Hit.p.X, rootPart.Position.Y, mouse.Hit.p.Z)
- local direction = (mousePos - rootPart.Position).Unit
- local targetCFrame = CFrame.new(rootPart.Position, rootPart.Position + direction)
- rootPart.CFrame = rootPart.CFrame:Lerp(targetCFrame, turnSpeed)
- end
- local moveConnection = game:GetService("RunService").RenderStepped:Connect(updateVelocityTowardsMouse)
- local turnConnection = game:GetService("RunService").RenderStepped:Connect(faceMouse)
- globalMoveConnection = moveConnection
- globalTurnConnection = turnConnection
- end)
- end
- end)
- userInputService.InputEnded:Connect(function(output, gameprocess)
- if gameprocess then return end
- if output.KeyCode == Enum.KeyCode.E and equipped == true then
- if canBeRealeased == true then
- canBeRealeased = false
- if casted == false then
- casted = true
- remoteEvents.End:FireServer()
- task.delay(10, function()
- casted = false
- end)
- end
- if globalMoveConnection then
- globalMoveConnection:Disconnect()
- end
- if globalTurnConnection then
- globalTurnConnection:Disconnect()
- end
- if globalVelocity then
- globalVelocity:Destroy()
- end
- local localCFrame = player.Character.HumanoidRootPart.CFrame
- remoteEvents.Dive:FireServer(localCFrame)
- local player = game.Players.LocalPlayer
- local cameraPart = createCameraPart(player, "Right")
- task.delay(cutceneTime, function()
- local camera = workspace.CurrentCamera
- camera.CameraType = Enum.CameraType.Custom
- if cameraPart then
- cameraPart:Destroy()
- end
- end)
- else
- if globalMoveConnection then
- globalMoveConnection:Disconnect()
- end
- if globalTurnConnection then
- globalTurnConnection:Disconnect()
- end
- if globalVelocity then
- globalVelocity:Destroy()
- end
- local localCFrame = player.Character.HumanoidRootPart.CFrame
- remoteEvents.Dive:FireServer(localCFrame)
- local player = game.Players.LocalPlayer
- local cameraPart = createCameraPart(player, "Right")
- task.delay(cutceneTime, function()
- local camera = workspace.CurrentCamera
- camera.CameraType = Enum.CameraType.Custom
- if cameraPart then
- cameraPart:Destroy()
- end
- end)
- end
- local tweenInfo = TweenInfo.new(.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
- local tweenFov = tweenService:Create(camera, tweenInfo, { FieldOfView = 70 })
- tweenFov:Play()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement