Advertisement
Firebirdzz

Example #1.1

Dec 19th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.55 KB | None | 0 0
  1. -- Controllable Wave Hunter Script (Client control)
  2.  
  3. local tool = script.Parent.Parent
  4. local userInputService = game:GetService("UserInputService")
  5. local runService = game:GetService("RunService")
  6. local replicatedStorage = game:GetService("ReplicatedStorage")
  7. local effects = tool.Effects.E
  8. local remoteEvents = effects.RemoteEvents
  9. local tool = script.Parent.Parent
  10. local tweenService = game:GetService("TweenService")
  11.  
  12. local serverPartsFolder = replicatedStorage.ServerParts
  13. local serverParts = serverPartsFolder.Water.E
  14. local tweenService = game:GetService("TweenService")
  15. local workspaceFolder = workspace:WaitForChild("ServerEffectStorage")
  16.  
  17. local player = game.Players.LocalPlayer
  18. local character = player.Character
  19. local hmrp = character.HumanoidRootPart
  20. local mouse = player:GetMouse()
  21. local camera = workspace.CurrentCamera
  22.  
  23. cooldown = 10
  24.  
  25. equipped = false
  26. isPressing = false
  27.  
  28. minimumHoldTime = 6
  29. maximumHoldTime = 13
  30. cutceneTime = 3
  31. canBeRealeased = false
  32.  
  33. globalVelocity = nil
  34. globalTurnConnection = nil
  35. globalMoveConnection = nil
  36. currentSideVelocity = nil
  37. maxSideVelocity = nil
  38. sideAcceleration = nil
  39. dampingFactor = nil
  40.  
  41. tempTrue = true
  42. casted = false
  43.  
  44. -- // SCREENSHAKE SCRIPT \\
  45. local shakeDuration = 0
  46. local shakeMagnitude = 0
  47. local shakeTime = 0
  48. local Camera = workspace.CurrentCamera
  49.  
  50. local function Trigger(duration, magnitude)
  51.     shakeDuration = duration
  52.     shakeMagnitude = magnitude
  53.     shakeTime = 0
  54. end
  55.  
  56. local function LoadUpdate(dt)
  57.     if shakeDuration > 0 then
  58.         shakeTime = shakeTime + dt
  59.         if shakeTime >= shakeDuration then
  60.             shakeDuration = 0
  61.             shakeMagnitude = 0
  62.             Camera.CFrame = Camera.CFrame + Camera.CFrame.LookVector
  63.         else
  64.             local dx = math.random(-shakeMagnitude, shakeMagnitude) * .1
  65.             local dy = math.random(-shakeMagnitude, shakeMagnitude) * .1
  66.             local dz = math.random(-shakeMagnitude, shakeMagnitude) * .1
  67.             Camera.CFrame = Camera.CFrame * CFrame.new(dx,dy,dz)
  68.         end
  69.     end
  70. end
  71.  
  72. game:GetService("RunService").RenderStepped:Connect(LoadUpdate)
  73. --
  74.  
  75. local function createCameraPart(player, side)
  76.     local character = player.Character or player.CharacterAdded:Wait()
  77.     local rootPart = character:WaitForChild("HumanoidRootPart")
  78.  
  79.     local cameraPart = Instance.new("Part")
  80.     cameraPart.Name = "CameraPart"
  81.     cameraPart.Anchored = true
  82.     cameraPart.CanCollide = false
  83.     cameraPart.Transparency = 1
  84.     cameraPart.Size = Vector3.new(1, 1, 1)
  85.     cameraPart.Parent = workspace
  86.  
  87.     local sideOffset = side == "right" and 1 or -1
  88.     local distance = 200
  89.     local height = 120
  90.  
  91.     local sideVector = rootPart.CFrame.RightVector * distance * sideOffset
  92.     local upwardVector = Vector3.new(0, height, 0)
  93.     local cameraPosition = rootPart.Position + sideVector + upwardVector
  94.  
  95.     cameraPart.CFrame = CFrame.new(cameraPosition, rootPart.Position)
  96.     local camera = workspace.CurrentCamera
  97.     camera.CameraType = Enum.CameraType.Scriptable
  98.     camera.CFrame = cameraPart.CFrame
  99.  
  100.     return cameraPart
  101. end
  102.  
  103. tool.Equipped:Connect(function()
  104.     equipped = true
  105. end)
  106.  
  107. tool.Unequipped:Connect(function()
  108.     equipped = false
  109.     if globalMoveConnection then
  110.     globalMoveConnection:Disconnect()
  111.     globalTurnConnection:Disconnect()
  112.     end
  113.     if globalVelocity then
  114.         globalVelocity:Destroy()
  115.     end
  116. end)
  117.  
  118.  
  119. userInputService.InputBegan:Connect(function(input, gameprocess)
  120.     if gameprocess then return end
  121.     if input.KeyCode == Enum.KeyCode.E and equipped == true and casted == false then
  122.        
  123.         task.spawn(function()
  124.             for i = 1, minimumHoldTime do
  125.                 wait(1)
  126.             end
  127.             canBeRealeased = true
  128.         end)
  129.        
  130.         task.spawn(function()
  131.             for i = 1, maximumHoldTime do
  132.                 wait(1)
  133.             end
  134.             if casted == false then
  135.                 casted = true
  136.  
  137.                 local localCFrame = character.HumanoidRootPart.CFrame
  138.                 remoteEvents.Dive:FireServer(localCFrame)
  139.                
  140.                 local player = game.Players.LocalPlayer
  141.                 local cameraPart = createCameraPart(player, "Right")
  142.                 task.delay(cutceneTime, function()
  143.                     local camera = workspace.CurrentCamera
  144.                     camera.CameraType = Enum.CameraType.Custom
  145.                     if cameraPart then
  146.                         cameraPart:Destroy()
  147.                     end
  148.                 end)
  149.                 wait(10)
  150.                 casted = false
  151.             end
  152.         end)
  153.        
  154.         print(player.Name.." has pressed E. It's being held down. Using attack: Wave Hunter.")
  155.         isPressing = true
  156.  
  157.         local localCFrame = character.HumanoidRootPart.CFrame
  158.        
  159.         remoteEvents:WaitForChild("Hold"):FireServer(localCFrame)
  160.        
  161.         task.delay(13.5, function()
  162.             local Flasher = effects.Lighting.Flash:Clone()
  163.             Flasher.Brightness = 1
  164.             local function WhiteColor()
  165.                 Flasher.TintColor = Color3.new(255,255,255)
  166.             end
  167.             local function BlackColor()
  168.                 Flasher.TintColor = Color3.new(0,0,0)
  169.             end
  170.             Flasher.Parent = game.Lighting 
  171.  
  172.             for i = 1,2 do wait(.02)
  173.                 WhiteColor()
  174.                 wait(.02)
  175.                 BlackColor()
  176.             end
  177.             game.Debris:AddItem(Flasher,0)
  178.             Trigger(1, 30)
  179.             wait(3)
  180.             Trigger(3, 15)
  181.             wait(1.5)
  182.             Trigger(5,6)
  183.         end)
  184.        
  185.         Trigger(1, 35)
  186.         task.delay(1, function()
  187.             Trigger(7, 20)
  188.             task.delay(7, function()
  189.             Trigger(5.5, 25)
  190.             end)
  191.         end)
  192.  
  193.        
  194.         -- Tweening the camera out, then view the player from above.
  195.         local tweenInfo = TweenInfo.new(.55, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
  196.         local tweenFov = tweenService:Create(camera, tweenInfo, { FieldOfView = 250 })
  197.         tweenFov:Play()
  198.        
  199.         local updatingCamera = false
  200.        
  201.         local originalMinZoom = player.CameraMinZoomDistance
  202.         local originalMaxZoom = player.CameraMaxZoomDistance
  203.  
  204.         local function forceZoomOut(targetZoom)
  205.             player.CameraMinZoomDistance = targetZoom
  206.             player.CameraMaxZoomDistance = targetZoom
  207.         end
  208.  
  209.         local function restoreZoom()
  210.             player.CameraMinZoomDistance = originalMinZoom
  211.             player.CameraMaxZoomDistance = originalMaxZoom
  212.         end
  213.  
  214.         forceZoomOut(100)
  215.  
  216.         task.delay(5, restoreZoom)
  217.        
  218.         local currentCFrame = camera.CFrame
  219.         local height = 50
  220.         local rotation = CFrame.Angles(math.rad(-60), 0, 0)
  221.         local newCFrame = CFrame.new(currentCFrame.Position.X, player.Character.HumanoidRootPart.Position.Y + height, currentCFrame.Position.Z) * rotation
  222.         camera.CFrame = newCFrame
  223.        
  224.        
  225.         local player = game.Players.LocalPlayer
  226.         local character = player.Character or player.CharacterAdded:Wait()
  227.         local hrp = character:WaitForChild("HumanoidRootPart")
  228.         local targetHeight = hrp.Position.Y + 15  
  229.  
  230.         local TweenService = game:GetService("TweenService")
  231.         local goal = {CFrame = hrp.CFrame + Vector3.new(0, targetHeight - hrp.Position.Y, 0)}
  232.         local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  233.         local liftTween = TweenService:Create(hrp, tweenInfo, goal)
  234.        
  235.         liftTween:Play()
  236.         liftTween.Completed:Connect(function()
  237.            
  238.         -- Debug, the start disconnect: immediately letting the player face the mouse's direction: --
  239.         local root = hmrp
  240.         local rootPos, mousePos = root.Position, mouse.Hit.Position
  241.         root.CFrame = CFrame.new(rootPos, Vector3.new(mousePos.X, rootPos.Y, mousePos.Z))
  242.         --
  243.            
  244.         local velocity = Instance.new("BodyVelocity")
  245.         velocity.Parent = player.Character.HumanoidRootPart
  246.         velocity.MaxForce = Vector3.new(10000,math.huge,10000)
  247.         velocity.Velocity = Vector3.new(0,100,0)
  248.         globalVelocity = velocity
  249.         -- Summary:
  250.         -- [1] left, right
  251.         -- [2] up, down
  252.         -- [3] back, forward
  253.        
  254.         local rootPart = character:WaitForChild("HumanoidRootPart")
  255.            
  256.         local speedUpCounter = 1
  257.            
  258.         local function updateVelocityTowardsMouse()
  259.            
  260.             if equipped == true then
  261.            
  262.             local mousePos = Vector3.new(mouse.Hit.p.X, rootPart.Position.Y, mouse.Hit.p.Z)
  263.             local playerPos = rootPart.Position
  264.             local direction = (mousePos - playerPos).Unit
  265.  
  266.             local forwardDirection = rootPart.CFrame.LookVector
  267.  
  268.             local dotProduct = forwardDirection:Dot(direction)
  269.  
  270.             if dotProduct > 0.5 then
  271.                 local sideFactor = math.clamp(dotProduct, 0.3, 1)
  272.                 direction = Vector3.new(direction.X * sideFactor, 0, direction.Z * sideFactor)
  273.  
  274.                         velocity.Velocity = direction * (38 * speedUpCounter)
  275.                         speedUpCounter += 0.015
  276.                
  277.             else
  278.                         if not player.PlayerGui:FindFirstChild("Too sharp turn") then
  279.                             print("User has took a too sharp turn, cancelled attack.")
  280.                             velocity:Destroy()
  281.                             globalMoveConnection:Disconnect()
  282.                             globalTurnConnection:Disconnect()
  283.                
  284.                             local gui = effects:WaitForChild("GUIs"):WaitForChild("Too sharp turn"):Clone()
  285.                             gui.Parent = player.PlayerGui
  286.                             local background = gui:WaitForChild("Background")
  287.                
  288.                             local startPosition = UDim2.new(1.1, 0, 0.8, 0)
  289.                             local targetPosition = UDim2.new(0.8, 0, 0.8, 0)
  290.  
  291.                             local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
  292.  
  293.                             local moveToTarget = tweenService:Create(background, tweenInfo, {Position = targetPosition})
  294.                             local moveToStart = tweenService:Create(background, tweenInfo, {Position = startPosition})
  295.  
  296.                             moveToTarget:Play()
  297.                             moveToTarget.Completed:Connect(function()
  298.                             wait(5)
  299.                             moveToStart:Play()
  300.                             task.delay(1, function()
  301.                                 gui:Destroy()
  302.                             end)
  303.                         end)   
  304.                     end
  305.                 end
  306.             end
  307.         end
  308.        
  309.         local function faceMouse()
  310.             local turnSpeed = 0.04
  311.             local runService = game:GetService("RunService")
  312.             local mousePos = Vector3.new(mouse.Hit.p.X, rootPart.Position.Y, mouse.Hit.p.Z)
  313.             local direction = (mousePos - rootPart.Position).Unit
  314.             local targetCFrame = CFrame.new(rootPart.Position, rootPart.Position + direction)
  315.             rootPart.CFrame = rootPart.CFrame:Lerp(targetCFrame, turnSpeed)
  316.         end
  317.        
  318.         local moveConnection = game:GetService("RunService").RenderStepped:Connect(updateVelocityTowardsMouse)
  319.         local turnConnection = game:GetService("RunService").RenderStepped:Connect(faceMouse)
  320.         globalMoveConnection = moveConnection
  321.         globalTurnConnection = turnConnection      
  322.         end)
  323.     end
  324. end)
  325.  
  326.  
  327. userInputService.InputEnded:Connect(function(output, gameprocess)
  328.     if gameprocess then return end
  329.     if output.KeyCode == Enum.KeyCode.E and equipped == true then
  330.         if canBeRealeased == true then
  331.             canBeRealeased = false
  332.            
  333.         if casted == false then
  334.             casted = true
  335.             remoteEvents.End:FireServer()
  336.             task.delay(10, function()
  337.             casted = false
  338.             end)
  339.         end
  340.            
  341.         if globalMoveConnection then
  342.             globalMoveConnection:Disconnect()
  343.         end
  344.         if globalTurnConnection then
  345.             globalTurnConnection:Disconnect()
  346.         end
  347.         if globalVelocity then
  348.             globalVelocity:Destroy()
  349.         end
  350.            
  351.         local localCFrame = player.Character.HumanoidRootPart.CFrame
  352.             remoteEvents.Dive:FireServer(localCFrame)
  353.            
  354.             local player = game.Players.LocalPlayer
  355.             local cameraPart = createCameraPart(player, "Right")
  356.             task.delay(cutceneTime, function()
  357.                 local camera = workspace.CurrentCamera
  358.                 camera.CameraType = Enum.CameraType.Custom
  359.                 if cameraPart then
  360.                     cameraPart:Destroy()
  361.                 end
  362.             end)
  363.            
  364.         else
  365.             if globalMoveConnection then
  366.                 globalMoveConnection:Disconnect()
  367.             end
  368.             if globalTurnConnection then
  369.                 globalTurnConnection:Disconnect()
  370.             end
  371.             if globalVelocity then
  372.                 globalVelocity:Destroy()
  373.             end
  374.  
  375.             local localCFrame = player.Character.HumanoidRootPart.CFrame
  376.             remoteEvents.Dive:FireServer(localCFrame)
  377.            
  378.             local player = game.Players.LocalPlayer
  379.             local cameraPart = createCameraPart(player, "Right")
  380.             task.delay(cutceneTime, function()
  381.                 local camera = workspace.CurrentCamera
  382.                 camera.CameraType = Enum.CameraType.Custom
  383.                 if cameraPart then
  384.                     cameraPart:Destroy()
  385.                 end
  386.             end)
  387.         end
  388.  
  389.         local tweenInfo = TweenInfo.new(.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
  390.         local tweenFov = tweenService:Create(camera, tweenInfo, { FieldOfView = 70 })
  391.         tweenFov:Play()
  392.     end
  393. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement