------------------------------------------------------------------------------------------------------------------------------------------------------
--  Events
------------------------------------------------------------------------------------------------------------------------------------------------------


UserInputService.InputBegan:connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.S then
		CurrentPath = nil
		MouseHolding = false
		if PathingThread then coroutine.yield(PathingThread) end 
		
		LocalCharacter:WaitForChild('Humanoid'):MoveTo(LocalCharacter.HumanoidRootPart.Position)
	end
end)

LocalMouse.Button2Down:connect(function()
	MouseHolding = true

	repeat --wait(0.05)
		if PathingThread then coroutine.yield(PathingThread) end 

		PathingThread = coroutine.resume(coroutine.create(function()
			CreatePath()
		end))
		
		print(1)
		wait(0.05)
	until MouseHolding == false or CurrentPath == nil
end)

LocalMouse.Button2Up:connect(function()
  MouseHolding = false
end)
