Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Controllable Water beam - Ground lock (clientSided)
- local tool = script.Parent.Parent
- local player = game.Players.LocalPlayer
- local char = player.Character
- local hmrp = char.HumanoidRootPart
- local character = player.Character
- local userInputService = game:GetService("UserInputService")
- local isPressing = false
- local equipped = false
- local effects = tool.Effects.C
- local remoteEvents = effects.RemoteEvents
- hasToBeForced = false
- Mouse = player:GetMouse()
- renderStep = nil
- local MaxPlaceDistance = 250
- raycastParams = nil
- counter = 0
- -- // Cooldown Debug for smoothening the beam --
- firedOnce = false
- firedCooldown = 2
- firedCooldownOver = false
- globalVelocity = nil
- globalLocalCFrame = nil
- --[[ IMPORTANT DEBUG NOTE
- Since for some reason the raycastparams do not work, until i get it working, i empty the servereffectstorage on the client.
- - Solved]]
- tool.Equipped:Connect(function()
- equipped = true
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- if isPressing == true then
- isPressing = false
- end
- end)
- 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
- 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)
- userInputService.InputBegan:Connect(function(input, gameprocess)
- if gameprocess then return end
- if input.KeyCode == Enum.KeyCode.C and equipped == true then
- print(player.Name.." has pressed Z. It's being held down. Charging attack.")
- isPressingZ = true
- local localCFrame = character.HumanoidRootPart.CFrame
- while isPressingZ == true do
- counter += 1
- Trigger(.67, 1)
- print("Attack is being charged. Current level: "..counter)
- if counter < 6 then
- remoteEvents.ChargeUp:FireServer(counter, localCFrame)
- end
- wait(script.ChargeTime.Value)
- if counter == 5 then
- print("Cannot Charge past charge 5. Any additional charge will be useless.")
- end
- if counter == 3 then
- end
- if counter == 4 then
- end
- if counter == 12 then
- isPressingZ = false
- print("Creating forced attack.")
- -- Creating forced attack after 7 seconds --
- Trigger(.67, 1)
- print("Attack is being forced. Current level must be 5. It is: "..counter)
- remoteEvents.StartAttack:FireServer(counter, localCFrame)
- local canFireTheBeam = true
- raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {player.Character:GetChildren(),workspace:WaitForChild("ServerEffectStorage"):GetDescendants()}
- warn(raycastParams.FilterDescendantsInstances)
- raycastParams.FilterType = Enum.RaycastFilterType.Exclude
- for _, obj in pairs(raycastParams.FilterDescendantsInstances) do
- warn(obj)
- end
- Trigger(tool.Configuration.C:WaitForChild("Charge 5 ShakeDuration").Value, 9)
- task.delay(tool.Configuration.C:WaitForChild("Charge 5 ShakeDuration").Value, function()
- canFireTheBeam = false
- effects.RemoteEvents.EndBeam:FireServer()
- end)
- renderStep = game:GetService("RunService").RenderStepped:Connect(function()
- if canFireTheBeam == true then
- local mouseHitPosition = Mouse.Hit.Position
- local direction = (mouseHitPosition - player.Character.HumanoidRootPart.Position).Unit
- local distance = (mouseHitPosition - player.Character.HumanoidRootPart.Position).Magnitude
- if distance > MaxPlaceDistance then
- distance = MaxPlaceDistance
- end
- local targetPosition = player.Character.HumanoidRootPart.Position + direction * distance
- local rayOrigin = targetPosition
- local rayDirection = Vector3.new(0,-1000,0)
- local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
- if raycastResult then
- targetPosition = raycastResult.Position
- end
- local TargetCFrame = CFrame.new(targetPosition) * CFrame.new(0,tool.Configuration.C:WaitForChild("Charge 5 Y Offset"),0)
- localCFrame = character.HumanoidRootPart.CFrame
- effects.RemoteEvents.StartBeam:FireServer(TargetCFrame, localCFrame)
- else
- Trigger(.1, 10)
- -- task.delay(.1, function()
- renderStep:Disconnect()
- print("Renderstep disconnected.")
- renderStep = nil --end)
- raycastParams = nil
- end
- end)
- counter = 0
- isPressing = false
- hasToBeForced = false
- end
- end
- end
- end)
- userInputService.InputEnded:Connect(function(output, gameprocess)
- if gameprocess then return end
- if output.KeyCode == Enum.KeyCode.C and equipped == true then
- local canFireTheBeam = true
- isPressingZ = false
- print(player.Name.." has stopped pressing Z.")
- print("Current counter level: "..counter)
- local localCFrame = character.HumanoidRootPart.CFrame
- if counter ~= 4 and counter ~=5 and counter ~=6 and counter ~=7 and counter ~=8 and counter ~=9 and counter ~=10 and counter ~=11 and counter ~=12 then
- remoteEvents.StartAttack:FireServer(counter, localCFrame)
- end
- if counter == 4 then
- raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {player.Character:GetChildren(),workspace:WaitForChild("ServerEffectStorage"):GetDescendants()}
- warn(raycastParams.FilterDescendantsInstances)
- raycastParams.FilterType = Enum.RaycastFilterType.Exclude
- for _, obj in pairs(raycastParams.FilterDescendantsInstances) do
- warn(obj)
- end
- -- DEBUG --
- local desc = workspace.ServerEffectStorage:GetDescendants()
- for _, child in pairs(desc) do
- if child:IsA("Model") then
- child:Destroy()
- end
- end
- -- DEBUG --
- Trigger(tool.Configuration.C:WaitForChild("Charge 4 ShakeDuration").Value, 5)
- task.delay(tool.Configuration.C:WaitForChild("Charge 4 Duration").Value, function()
- canFireTheBeam = false
- effects.RemoteEvents.EndMiniBeam:FireServer()
- end)
- renderStep = game:GetService("RunService").RenderStepped:Connect(function()
- if canFireTheBeam == true then
- local mouseHitPosition = Mouse.Hit.Position
- local direction = (mouseHitPosition - player.Character.HumanoidRootPart.Position).Unit
- local distance = (mouseHitPosition - player.Character.HumanoidRootPart.Position).Magnitude
- if distance > MaxPlaceDistance then
- distance = MaxPlaceDistance
- end
- local targetPosition = player.Character.HumanoidRootPart.Position + direction * distance
- local rayOrigin = targetPosition
- local rayDirection = Vector3.new(0,-1000,0)
- local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
- if raycastResult then
- targetPosition = raycastResult.Position
- end
- local TargetCFrame = CFrame.new(targetPosition) * CFrame.new(0,tool.Configuration.C:WaitForChild("Charge 4 Y Offset"),0)
- localCFrame = character.HumanoidRootPart.CFrame
- effects.RemoteEvents.StartMiniBeam:FireServer(TargetCFrame, localCFrame)
- Trigger(.1, 10)
- else
- Trigger(.1, 10)
- renderStep:Disconnect()
- print("Renderstep disconnected.")
- renderStep = nil
- raycastParams = nil
- end
- end)
- end
- if counter == 5 or counter == 6 or counter == 7 or counter == 8 or counter == 9 or counter == 10 or counter == 11 then
- raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {player.Character:GetChildren(),workspace:WaitForChild("ServerEffectStorage"):GetDescendants()}
- warn(raycastParams.FilterDescendantsInstances)
- raycastParams.FilterType = Enum.RaycastFilterType.Exclude
- for _, obj in pairs(raycastParams.FilterDescendantsInstances) do
- warn(obj)
- end
- -- FoV --
- local camera = workspace.CurrentCamera
- local tweenService = game:GetService("TweenService")
- --camera.FieldOfView = 70
- local tweenInfo = TweenInfo.new(.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
- local tweenFov = tweenService:Create(camera, tweenInfo, { FieldOfView = 100 })
- tweenFov:Play()
- -- FoV II --
- tweenFov.Completed:Connect(function()
- wait(6.5)
- local tweenInfo2 = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
- local tweenFov2 = tweenService:Create(camera, tweenInfo2, { FieldOfView = 140 })
- tweenFov2:Play()
- tweenFov2.Completed:Connect(function()
- wait()
- local tweenInfo3 = TweenInfo.new(.8, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
- local tweenFov3 = tweenService:Create(camera, tweenInfo3, { FieldOfView = 70 })
- tweenFov3:Play()
- end)
- end)
- --
- Trigger(tool.Configuration.C:WaitForChild("Charge 5 ShakeDuration").Value, 9)
- task.delay(tool.Configuration.C:WaitForChild("Charge 5 Duration").Value, function()
- canFireTheBeam = false
- effects.RemoteEvents.EndBeam:FireServer()
- end)
- renderStep = game:GetService("RunService").RenderStepped:Connect(function()
- if canFireTheBeam == true then
- local mouseHitPosition = Mouse.Hit.Position
- local direction = (mouseHitPosition - player.Character.HumanoidRootPart.Position).Unit
- local distance = (mouseHitPosition - player.Character.HumanoidRootPart.Position).Magnitude
- if distance > MaxPlaceDistance then
- distance = MaxPlaceDistance
- end
- local targetPosition = player.Character.HumanoidRootPart.Position + direction * distance
- local rayOrigin = targetPosition
- local rayDirection = Vector3.new(0,-1000,0)
- local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
- if raycastResult then
- targetPosition = raycastResult.Position
- end
- local TargetCFrame = CFrame.new(targetPosition) * CFrame.new(0,tool.Configuration.C:WaitForChild("Charge 5 Y Offset"),0)
- localCFrame = globalLocalCFrame -- character.HumanoidRootPart.CFrame
- effects.RemoteEvents.StartBeam:FireServer(TargetCFrame, localCFrame)
- --[[ if firedOnce == false then
- effects.RemoteEvents.StartBeam:FireServer(TargetCFrame, localCFrame)
- firedOnce = true
- elseif firedOnce == true then
- if firedCooldownOver == false then
- task.delay(2, function()
- firedCooldownOver = true
- end)
- elseif firedCooldownOver == true then
- effects.RemoteEvents.StartBeam:FireServer(TargetCFrame, localCFrame)
- end
- end]]
- else
- Trigger(.1, 10)
- -- task.delay(.1, function()
- renderStep:Disconnect()
- print("Renderstep disconnected.")
- renderStep = nil --end)
- raycastParams = nil
- end
- end)
- end
- counter = 0
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement