--Functions--



UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	if input.KeyCode == Enum.KeyCode.X and Debounce == 1 and Enabled == true and Tool.Equip.Value == true and Tool.Active.Value == "None"  then
		ButtonDown = true
		Debounce = 2
		local properties = {FieldOfView = 50}
		local info1 = TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
		local tween = ts:Create(game.Workspace.CurrentCamera,info1,properties)
		tween:Play()
		local ChargeEffect = script.Charge.Particles.Charge1:Clone()
		local Character = Player.Character
		ChargeEffect.Parent = Character.HumanoidRootPart
		ChargeEffect:Emit(25)
		game.Debris:AddItem(ChargeEffect,2)
		local StartSfx = game.ReplicatedStorage["Water Wheel"].Sounds.SwordSFX:Clone() -- Sound Effect
		StartSfx.Parent = Player.Character.HumanoidRootPart
		StartSfx.MaxDistance = 150
		StartSfx.TimePosition = 0
		StartSfx:Play()	
		Player.Character.Humanoid.WalkSpeed = 5
		Player.Character.Humanoid.JumpPower = 0
       
		local CameraShaker = require(game.ReplicatedStorage["Water Wheel"].Modules.CameraShaker)
		local camshake = CameraShaker.new(Enum.RenderPriority.Camera.Value,function(shakeCFrame)
			camera.CFrame = camera.CFrame * shakeCFrame
		end)
		camshake:Start()
		camshake:Shake(CameraShaker.Presets.OldBump)

		script.Wheel:FireServer("Water Wheel", mouse.Hit.Position)
		ButtonDown = true
		local properties = {FieldOfView = 85}
		local info2 = TweenInfo.new(0.25,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
		local tween2 = ts:Create(game.Workspace.CurrentCamera,info2,properties)
		tween2:Play()
		Player.Character.Humanoid.WalkSpeed = 0
		Player.Character.Humanoid.JumpPower = 0
		task.wait(0.5)
		local BV = Instance.new("BodyVelocity")
		BV.MaxForce = Vector3.new(300000,0,300000)
		BV.Parent = c.HumanoidRootPart
		
		while ButtonDown == true and Player.Character.HumanoidRootPart.Anchored ~= true do
			c.HumanoidRootPart.CFrame = CFrame.new(c.HumanoidRootPart.Position, Vector3.new(mouse.Hit.Position.X,c.HumanoidRootPart.Position.Y,mouse.Hit.Position.Z))
			BV.Velocity = c.HumanoidRootPart.CFrame.lookVector * 80
			RS.Heartbeat:Wait()
			
		end
		
	
		Enabled = true
		BV:Destroy()
		
		
	end
end)


UIS.InputEnded:Connect(function(input, IsTyping)
	if IsTyping then return end
	if input.KeyCode == Enum.KeyCode.X and Tool.Equip.Value == true and Tool.Active.Value == "None" and Debounce == 2 and 	ButtonDown == true then
		Debounce = 3
		
		script.Wheel:FireServer("Stop", mouse.Hit.Position)
		local properties = {FieldOfView = 70}
		local info3 = TweenInfo.new(0.25,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
		local tween3 = ts:Create(game.Workspace.CurrentCamera,info3,properties)
		tween3:Play()
		local CameraShaker = require(game.ReplicatedStorage["Water Wheel"].Modules.CameraShaker)
		local camshake = CameraShaker.new(Enum.RenderPriority.Camera.Value,function(shakeCFrame)
			camera.CFrame = camera.CFrame * shakeCFrame
		end)
		camshake:Start()
		camshake:Shake(CameraShaker.Presets.OldBump)
		ButtonDown = false
		Key = nil
		wait(0.7)
		Tool.Active.Value = "None"
		Player.Character.Humanoid.WalkSpeed = 16
		Player.Character.Humanoid.JumpPower = 50
		wait(cooldown)
		Debounce = 1
	end
end)