Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Dive (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 isPressingQ = false
- local equipped = false
- local effects = tool.Effects.Q
- local remoteEvents = effects.RemoteEvents
- local mouse = player:GetMouse()
- clientTarget = nil
- globalCFrame = nil
- targetCFrame = nil
- globalRangeLimit = nil
- globalWeld = nil
- charDescendantTable = {}
- -- Config --
- local MaxPlaceDistance = 110
- --
- tool.Equipped:Connect(function()
- equipped = true
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- end)
- local function CreateRaycastParams()
- local raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {clientTarget, char}
- raycastParams.CollisionGroup = "Default"
- raycastParams.FilterType = Enum.RaycastFilterType.Exclude
- return raycastParams
- end
- local function getGroundPosition(position)
- local groundRaycastParams = RaycastParams.new()
- groundRaycastParams.FilterDescendantsInstances = {char, clientTarget, char:GetDescendants(), workspace:WaitForChild("ServerEffectStorage"):GetDescendants()}
- groundRaycastParams.FilterType = Enum.RaycastFilterType.Exclude
- local groundRay = workspace:Raycast(position, Vector3.new(0, -100,0), groundRaycastParams)
- if groundRay then
- return groundRay.Position
- else
- return position
- end
- end
- local function UpdateTargetCFrame()
- local Origin = hmrp.Position
- local MousePosition = mouse.Hit.p
- local Direction = (MousePosition - Origin).unit
- local raycastParams = CreateRaycastParams()
- local RayCastResult = workspace:Raycast(Origin, Direction * MaxPlaceDistance, raycastParams)
- local TargetPosition
- if RayCastResult then
- TargetPosition = RayCastResult.Position
- else
- TargetPosition = Origin + Direction * MaxPlaceDistance
- end
- TargetPosition = getGroundPosition(TargetPosition)
- clientTarget.Position = TargetPosition
- end
- userInputService.InputBegan:Connect(function(input, gameprocess)
- if gameprocess then return end
- if input.KeyCode == Enum.KeyCode.Q and equipped == true then
- print(player.Name.." has pressed Q. It's being held down.")
- local localCFrame = character.HumanoidRootPart.CFrame
- remoteEvents.Press:FireServer(localCFrame)
- --// Creating a client target \\--
- isPressingQ = true
- local hipHeight = character.Humanoid.HipHeight
- local target = game:GetService("ReplicatedStorage"):WaitForChild("ServerParts"):WaitForChild("Water"):WaitForChild("Q"):WaitForChild("Target"):Clone()
- target.Parent = workspace
- clientTarget = target
- local rangeLimit = game:GetService("ReplicatedStorage"):WaitForChild("ServerParts"):WaitForChild("Water"):WaitForChild("Q"):WaitForChild("RangeLimit"):Clone()
- rangeLimit.Parent = workspace
- rangeLimit.CFrame = localCFrame * CFrame.new(0,-hipHeight,0)
- rangeLimit.Parent = char
- globalRangeLimit = rangeLimit
- local weld = Instance.new("WeldConstraint")
- weld.Part0 = rangeLimit
- weld.Part1 = character.HumanoidRootPart
- weld.Parent = char
- globalWeld = weld
- -- Get the player ignore list immediately, once. --
- -- Discontinued: now uses CollisionGroup.
- while isPressingQ == true do
- wait()
- UpdateTargetCFrame()
- end
- end
- end)
- userInputService.InputEnded:Connect(function(output, gameprocess)
- if gameprocess then return end
- if output.KeyCode == Enum.KeyCode.Q and equipped == true then
- print(player.Name.." has stopped pressing Q.")
- isPressingQ = false
- globalWeld:Destroy()
- local localCFrame = character.HumanoidRootPart.CFrame
- globalCFrame = localCFrame
- targetCFrame = clientTarget.CFrame
- remoteEvents.Release:FireServer(globalCFrame,targetCFrame)
- task.spawn(function()
- for i = 1,130 do wait()
- globalRangeLimit.Attachment.Ring.Rate -= 1
- end
- globalRangeLimit:Destroy()
- end)
- -- FoV --
- local camera = workspace.CurrentCamera
- local tweenService = game:GetService("TweenService")
- local tweenInfo = TweenInfo.new(.55, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
- local tweenFov = tweenService:Create(camera, tweenInfo, { FieldOfView = 100 })
- tweenFov:Play()
- -- FoV II --
- tweenFov.Completed:Connect(function()
- local tweenInfo2 = TweenInfo.new(.4, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
- local tweenFov2 = tweenService:Create(camera, tweenInfo, { FieldOfView = 40 })
- tweenFov2:Play()
- clientTarget:Destroy()
- end)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement